[Haskell-cafe] Generalized monadic exception handling with monad-peel

Anders Kaseorg andersk at MIT.EDU
Wed Nov 3 18:35:05 EDT 2010

On Wed, 3 Nov 2010, Bas van Dijk wrote:
> Something else: In the soon to be released base-4.3 the block and 
> unblock functions will be deprecated in favor of mask. It would be great 
> if you can also add these new functions to Control.Exception.Peel:

Yeah, I was putting off learning how to deal with conditional compilation, 
but now that I’ve looked it seems easy enough.  Your definitions look 
right to me.

> Finally, would you also like to add wrapped functions for alloca and 
> friends from all the Foreign modules?

Michael Snoyman asked me the same question [1], and my thinking is that 
using liftIOOp with the Foreign allocation functions is already just as 
easy as using liftIO with normal IO actions:

  liftIOOp alloca $ \ptr -> frobnicate ptr
  liftIOOp (allocaBytes 17) $ \ptr -> frobnicate ptr

which suggests that maintaining a wrapper library would not be much of a 
win.  The same goes with functions like withMVar.

I’d be happy to hear arguments otherwise; or maybe the right answer is to 
clarify this in the documentation somehow?


[1] http://docs.yesodweb.com/blog/invertible-monads-exceptions-allocations/#comment-92915627

More information about the Haskell-Cafe mailing list