
3 Oct
2006
3 Oct
'06
3:49 a.m.
On Tue, Oct 03, 2006 at 10:44:49AM +1000, Thomas Conway wrote:
I've been [trying to] grapple with the various monads and transformers, and it occurs to me that the standard instance for Either as a monadic type is unnecessarily restrictive. Is there a compelling reason that it is not just
instance Monad (Either e) where return = Right (Left e) >>= f = Left e (Right x) >>= f = f x
abort = Left
That is the definition one would expect, but the restriction was added so that the instance could include a definition of fail. It's evidence that including fail in Monad is a wart, IMO. Using strings to represent errors has severe limitations.