3 ms·
The behavior of hGetContents is documented at http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#v%3AhGetContents http://www.haskell.org/
by shrughes 17y ago
The behavior of hGetContents is documented at http://www.haskell.org/ghc/docs/latest/html/libraries/base/System-IO.html#v%3AhGetContents http://www.haskell.org/ghc/docs/latest/html/libraries/base/S... .
If you write
do h <- openFile "foo.txt" ReadMode
x <- hGetContents h
putStr x
you'll get different behavior than if you write
do h <- openFile "foo.txt" ReadMode
x <- hGetContents h
hClose h
putStr x
In the first example, you'll print out the contents of the file. In the latter, you'll print out nothing.