[Haskell-cafe] Speed of Error handling with Continuations vs. Eithers

Antoine Latter aslatter at gmail.com
Sat May 15 22:20:53 EDT 2010


On Fri, May 14, 2010 at 4:25 PM, Derek Elkins <derek.a.elkins at gmail.com> wrote:
> You did it wrong.  All you did was Church encode the Either type.
> Your bind is still doing a case-analysis.  All you have to do is use
> ContT r (Either e).  The bind implementation for ContT is completely
> independent of the underlying monad.  It doesn't even require the m in
> ContT r m to be a functor, let alone a monad.  Therefore the ContT
> bind doesn't do any case-analysis because it doesn't know anything
> about the underlying monad.  One way to look at what is happening is
> to compare it to Andrzej Filiniski's work in "Representing Monads" and
> "Representing Layered Monads".
>

Here's a bit more fleshed out version of what Derek is talking about,
for those following along at home:

http://hpaste.org/fastcgi/hpaste.fcgi/view?id=25515#a25515

Derek - should I be doing something smarter in 'catch'? I couldn't
think of anything obvious.

Antoine


More information about the Haskell-Cafe mailing list