[Haskell-cafe] ErrorT vs Either

Daniel Fischer daniel.is.fischer at googlemail.com
Mon May 16 23:27:22 CEST 2011

On Monday 16 May 2011 23:05:22, Yves Parès wrote:
> Probably because in the instance of Monad Either, fail has not been
> overloaded, and still has its default implementation:
> fail = error

Right. It used to be different in mtl-1.*, when there was an

instance Error e => Monad (Either e) where
  return = Right
  Left err >>= _ = Left err
  Right x >>= k = k x
  fail msg = strMsg msg

defined in Control.Monad.Error.
Now we have

instance Monad (Either e) where ...

defined in Control.Monad.Instances, and there's no method to get an 
arbitrary e from a String (except error).

> Whereas runErrorT explicitely catches the exception.

`catches' is the wrong word, the Monad instance of ErrorT,

instance (Monad m, Error e) => Monad (ErrorT e m) where ...


    fail msg = ErrorT $ return (Left (strMsg msg))

That's probably what you meant, though.

More information about the Haskell-Cafe mailing list