[project @ 2000-08-15 14:12:18 by simonmar]
[ghc-hetmet.git] / ghc / tests / concurrent / should_run / conc005.hs
1 module Main where
2
3 import Concurrent
4
5 -- same as conc004, but using the ChannelVar abstraction
6
7 main = do
8   v <- newCVar
9   done <- newEmptyMVar
10   let
11         reader = do
12             c <- readCVar v
13             if (c == '\n') 
14                 then putMVar done ()
15                 else do putChar c; reader
16
17         writer []     = do writeCVar v '\n'; return ()
18         writer (c:cs) = do writeCVar v c;    writer cs
19
20   forkIO reader
21   writer "Hello World"
22   takeMVar done
23