[Haskell-cafe] Re: MonadCatchIO, finally and the error monad

Sterling Clover s.clover at gmail.com
Mon Oct 18 21:34:53 EDT 2010


On Mon, Oct 18, 2010 at 8:50 AM, Michael Snoyman <michael at snoyman.com> wrote:

> The point here is that we want to treat these things very differently.
> Just take a look at the runHandler code in the Yesod.Handler module:
> runtime exceptions need to be wrapped up in an internal server error,
> whereas "Left" values from the ErrorT get "case"d on. I understand
> that all of this could be done with extensible exceptions, but that's
> really just taking something which is currently explicit and
> type-checkable and making it implicit. It really does seem to me to be
> a typical dynamic-versus-static issue.

I fail to see how this is a dynamic-static issue. You're already
forced to catch exceptions and wrap them in a MLeft, and then later
you force the MLeft and MRight values in to a uniform representation
which you then case on. Catching a special exception type for exit and
forcing it into the same ultimate union representation doesn't seem
conceptually any more difficult, and in fact removes the need to
reason about two types of exceptions throughout the rest of the code
base.

I've got a large project that is based on a transformer stack over IO,
and one of my ongoing regrets has been that I went with Either as well
as extensible exceptions -- there's never been a genuine payoff, and
there have been more than a few headaches.

Cheers,
Sterl.


More information about the Haskell-Cafe mailing list