summaryrefslogtreecommitdiff
path: root/bitlength/consumer.icl
diff options
context:
space:
mode:
Diffstat (limited to 'bitlength/consumer.icl')
-rw-r--r--bitlength/consumer.icl26
1 files changed, 16 insertions, 10 deletions
diff --git a/bitlength/consumer.icl b/bitlength/consumer.icl
index 67a61ec..7d5c373 100644
--- a/bitlength/consumer.icl
+++ b/bitlength/consumer.icl
@@ -3,18 +3,24 @@ module consumer
import StdEnv
import producer
-Start :: *World -> *World
-Start w
+echo :: a *World -> *World | toString a
+echo s w
# (io,w) = stdio w
-# io = fwrites ("See, I can have 64 bits! " +++ toString (2^63-1) +++ "\n") io
-# io = consume 0 1 io
+# io = io <<< toString s <<< "\n"
# (ok,w) = fclose io w
+| not ok = abort "Couldn't close stdio"
+| otherwise = w
+
+Start :: *World -> *World
+Start w
+# w = echo " Producer - Consumer" w
+# w = consume 0 1 w
= w
where
- consume :: !Int !Int *File -> *File
- consume i n io
- # (n,io) = (produce n, io)
- # io = fwrites (toString i +++ " : " +++ toString n +++ "\n") io
- | n <> 0 = consume (i+1) n io
- | otherwise = io
+ consume :: !Int !Int *World -> *World
+ consume i n w
+ # n = abs (produce n)
+ # w = echo n w
+ | n <> 0 = consume (i+1) n w
+ | otherwise = w