[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / misc / examples / io / io017 / Main.hs
1 main =
2       hSetBuffering stdout NoBuffering                  >>
3       putStr   "Enter an integer: "                     >>
4       readLine                                          >>= \ x1 -> 
5       putStr   "Enter another integer: "                >>
6       readLine                                          >>= \ x2 -> 
7       putStr  ("Their sum is " ++ show (read x1+ read x2) ++ "\n")
8
9  where readLine = isEOF                                 >>= \ eof ->
10                   if eof then return []
11                   else getChar                          >>= \ c ->
12                        if c `elem` ['\n','\r'] then
13                           return []
14                        else
15                           readLine                      >>= \ cs ->
16                           return (c:cs)
17