[project @ 2001-08-22 11:45:06 by sewardj]
[ghc-hetmet.git] / ghc / tests / lib / IO / hGetChar001.hs
1 import IO
2
3 main = do
4  hSetBuffering stdout NoBuffering
5  putStr   "Enter an integer: "
6  x1 <- readLine
7  putStr   "Enter another integer: "
8  x2 <- readLine
9  putStr  ("Their sum is " ++ show (read x1 + read x2 :: Int) ++ "\n")
10
11  where readLine = do
12            eof <- isEOF
13            if eof then return [] else do
14            c <- getChar
15            if c `elem` ['\n','\r'] 
16                 then return []
17                 else do cs <- readLine
18                         return (c:cs)