[Haskell-cafe] MonadCatchIO and bracket.

Sterling Clover s.clover at gmail.com
Mon Jun 28 19:45:10 EDT 2010

There’s a history of rich debate and discussion on these issues coming
from the scheme world, where it takes the guise of implementing
unwind-protect in the presence of call/cc. Kent Pitman’s take is
presented here:


There’s some context given in the following ltu discussion:

Will Clinger’s notes on his revised implementation are particularly useful:

Note that none of the implementations translate directly, I think, as
they rely on top-level mutable state.

In any case, my take is the following -- first, remove the ContT
instance from the CatchIO package as it is obviously wrong. Next,
don’t use ContT in the presence of exceptions. There are few cases
where one really needs to do so, given  that exceptions provide a
powerful means of flow control themselves. Finally, it is much easier
to provide a bracket function with one-shot continuations (i.e.,
MonadExit), and doing so could well simplify most of the current uses
of ContT.


More information about the Haskell-Cafe mailing list