[Haskell-cafe] MonadCatchIO and bracket.

Neil Brown nccb2 at kent.ac.uk
Mon Jun 28 16:08:24 EDT 2010


On 28/06/2010 20:02, Carl Howells wrote:
> While working this weekend on the Snap web framework, I ran into a
> problem.  Snap implements MonadCatchIO, so I thought I could just use
> bracket to handle resource acquisition/release in a safe manner.
> Imagine my surprise when bracket simply failed to run the release
> action sometimes.
>
> I quickly determined the times when it doesn't run are when Snap's
> monadic short-circuiting is used.  I dug into the source of bracket
> (in the transformers branch, though the mtl branch has the same
> behavior in these cases, with slightly different code), and the reason
> why quickly became obvious:
>    

See also this recent thread on haskell-cafe: 
http://www.haskell.org/pipermail/haskell-cafe/2010-June/079198.html 
which concluded that the ContT instance in MonadCatchIO is broken.  I 
think as you say, the instances of that library are flawed when dealing 
with monads that can alter the control flow.

Thanks,

Neil.


More information about the Haskell-Cafe mailing list