[Haskell-cafe] A Question about withFile

Bin Shi powerman1st at gmail.com
Wed Jul 25 11:59:55 CEST 2012


Hello,

I wrote a simple test program as

main = do
    withFile "a.txt" ReadMode (\h -> do
        c <- hGetContents h
        putStrLn c)

then I got my expected results: I'm a.txt

but if I changed to

main = do
      c <- withFile "a.txt" ReadMode hGetContents
      putStrLn c

I got just a empty line.

Where am I wrong?

Thanks.



More information about the Haskell-Cafe mailing list