Final bikeshedding call: Fixing Control.Exception.bracket
Eyal Lotem
eyal.lotem at gmail.com
Thu Nov 13 10:12:51 UTC 2014
I'd like to emphasize that "bracket" is only one of multiple functions that
needs to be changed. Some of those that need to be changed are primops.
On Thu, Nov 13, 2014 at 9:47 AM, Merijn Verstraaten <merijn at inconsistent.nl>
wrote:
>
> > On 12 Nov 2014, at 23:33, Bardur Arantsson <spam at scientician.net> wrote:
> >
> > Is the code for this available for inspection somewhere? (I realize it
> > might change based on the outcome of this "poll", but...)
>
> There's no complete patch, but I believe the outline has been sketched
> before, anyway to repeat it. The current implementation of bracket is as
> follows:
>
> bracket
> :: IO a
> -> (a -> IO b)
> -> (a -> IO c)
> -> IO c
> bracket before after thing =
> mask $ \restore -> do
> a <- before
> r <- restore (thing a) `onException` after a
> _ <- after a
> return r
>
> A new version would look like:
>
> bracket before after thing =
> mask $ \restore -> do
> let atomicAfter = uninterruptibleMask . after
> a <- before
> r <- restore (thing a) `onException` atomicAfter a
> _ <- atomicAfter a
> return r
>
> Slightly different versions are possible and the other relevant bracketing
> functions mentioned in this thread can be treated similarly.
>
> Cheers,
> Merijn
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
--
Eyal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141113/bb7a6299/attachment.html>
More information about the Libraries
mailing list