[Haskell-cafe] problem with IO, strictness, and "let"
newsham at lava.net
Mon Jul 16 15:00:28 EDT 2007
>>> The problem is that you're closing the file twice. When you call any
>>> function of the getContents family, you assign to that function the
>>> responsibility to close the file, no sooner than it is no longer needed.
>>> Don't call hClose yourself, Bad Things will happen.
> If you close the file, the stream will suddenly end. I believe silent
> data corruption is worse than a crash :) (currently, hGetContents also
> truncates on I/O error, but that's much less common and syslog will tell
> you about it anyway)
Why can't hClose be more... um... lazy?
More information about the Haskell-Cafe