blob: 7d5c373b47831035ec489789bab1a5f632f9a2b6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
module consumer
import StdEnv
import producer
echo :: a *World -> *World | toString a
echo s w
# (io,w) = stdio w
# 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 *World -> *World
consume i n w
# n = abs (produce n)
# w = echo n w
| n <> 0 = consume (i+1) n w
| otherwise = w
|