[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:

http://www.nhplace.com/kent/PFAQ/unwind-protect-vs-continuations-overview.html

There’s some context given in the following ltu discussion:
http://lambda-the-ultimate.org/node/2966

Will Clinger’s notes on his revised implementation are particularly useful:
http://www.ccs.neu.edu/home/will/UWESC/uwesc.sch

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.

Cheers,
Sterl


More information about the Haskell-Cafe mailing list