News for hackers. Stuff that matters.
Re:Haskell IO for Imperative Programmers by shrughes on Monday November 09, 2009 @12:06PM (#931260)
The behavior of hGetContents is documented at 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.

There are no comments on this comment yet.