[Haskell-beginners] A first try

Jared Hance jaredhance at gmail.com
Sat Jun 25 15:21:57 CEST 2011


> I had thought hGetContents was lazy IO. If so, will that even work?
> The handle to the file will be closed before much of the file is even
> read.
> 
> Antoine

My guess is that the code I gave, which honestly is bad because I forgot
about readFile, is probably lazy rather than strict because according to
[0], readFile is lazy despite the fact that it doesn't require explicit
hClose.

Sorry, looks like I accidently hit r instead of L so it got taken off
the mailing list.

[0] http://book.realworldhaskell.org/read/io.html
    Look at that--the guts of the program take up only two lines!
    readFile returned a lazy String, which we stored in inpStr. We then
    took that, processed it, and passed it to writeFile for writing. 5
    comments



More information about the Beginners mailing list