
I suspect it is because the "fail" method for the 'Either' monad
instance makes use of Haskell's error function, since the instance is
defined generally and there is no way to override it for (Either
String a).
On May 16, 2011, Gracjan Polak
Control.Monad.Error Prelude> runErrorT (fail "msg") :: IO (Either String Int) Left "msg"
ErrorT defines fail to yield a pure value, rather than an exception. Since ErrorT is a different type than Either (though the runErrorT method yields an Either), the instances are different.
but
Control.Monad.Error Prelude> (fail "msg") :: (Either String Int) *** Exception: msg
The Monad instance for Either is defined generally, e.g. "instance Monad (Either a) where" so there is know way of typechecking a fail method that injects a string into "Left" in that case. -- Edward Amsden Student Computer Science Rochester Institute of Technology www.edwardamsden.com