[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / misc / examples / io / io018 / Main.hs
1 import LibSystem(getArgs)
2
3 main =   getArgs                            >>=        \ [user,host] ->
4          let username = (user ++ "@" ++ host) in
5          openFile username ReadWriteMode    >>=        \ cd          ->
6          hSetBuffering stdin NoBuffering    >>
7          hSetBuffering stdout NoBuffering   >>
8          hSetBuffering cd NoBuffering       >>
9          hPutStr cd speakString             >>
10          speak cd
11
12 speakString = "Someone wants to speak with you\n"
13
14 speak cd =
15          (hReady cd                         >>=        \ ready       ->
16          if ready then (hGetChar cd >>= putChar)
17          else return ()                     >>
18
19          hReady stdin                       >>=        \ ready       ->
20          if ready then (getChar >>= hPutChar cd)
21          else return ())                    >>
22
23          speak cd