Proposal: end lazy IO results with errors/exceptions

Brandon Allbery allbery.b at
Fri Jul 25 15:36:32 UTC 2014

On Fri, Jul 25, 2014 at 12:05 AM, Eric Mertens <emertens at> wrote:

> In any case, file descriptors are precious and it would make sense to
> hClose the file when you're done with it rather than wait and hope that the
> GC gets to closing your file.
> With this change we'd be introducing asynchronous minefields into code
> that don't need to exist.

hGetContents *is* an asynchronous minefield. This is attempting to make it
less so.

As for hClose, currently it is erroneous to hClose a handle on which
hGetContents has been done; you *cannot* hClose it at any point after you
have used hGetContents without losing data, as there is no way to know when
it is safe/correct to do so. If you believe otherwise, you may not
understand how it is implemented. (unsafeInterleaveIO is "unsafe" for a

brandon s allbery kf8nh                               sine nomine associates
allbery.b at                                  ballbery at
unix, openafs, kerberos, infrastructure, xmonad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Libraries mailing list