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