summaryrefslogtreecommitdiff
path: root/libraries/base/tests/IO/hGetLine002.hs
blob: 5185d9eea9b7a0e5156e77eccbb6a2fc2682c89f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
-- !!! testing hGetLine on a file without a final '\n'.

-- According to the Haskell 98 report, getLine should discard a line without a
-- closing newline character (see implementation of getLine). 
--
-- However, we don't believe that this is the right behaviour.

import System.IO
import System.IO.Error

main = catchIOError loop (\e -> print e)

loop = do 
  hSetBuffering stdin LineBuffering
  l <- hGetLine stdin
  putStrLn l
  loop