
27 Jun
2011
27 Jun
'11
7:58 a.m.
____________________ David Place Owner, Panpipes Ho! LLC http://panpipesho.com d@vidplace.com On Jun 27, 2011, at 3:50 AM, Heinrich Apfelmus wrote:
Good point, but this actually shows that withFile should be even lazier. In particular:
* The file should not be opened until the string is demanded. * The file should be closed as soon as the string has been demanded in full.
Suppose the file is only partially demanded as in the case I quoted earlier. print10 = do contents <- withFile "/usr/share/dict/words" ReadMode (\h -> hGetContents h) print $ take 10 contents The file would never be closed.