Proposal: end lazy IO results with errors/exceptions

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


On Fri, Jul 25, 2014 at 12:05 AM, Eric Mertens <emertens at gmail.com> 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
reason.)

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140725/44b8369c/attachment.html>


More information about the Libraries mailing list