[Haskell-cafe] Why Either = Left | Right instead of something like Result = Success | Failure

Daniel Fischer daniel.is.fischer at web.de
Fri May 28 15:21:47 EDT 2010


On Friday 28 May 2010 20:44:20, Donn Cave wrote:
> Quoth Vo Minh Thu <noteed at gmail.com>,
> ...
>
> > Control.Monad.Error provides an instance for Either.
>
> ... in the mtl transformer library, in case anyone else besides
> myself didn't know that. And I see it has to be there because
> it depends on the Error typeclass.

Which is considered a wart by some. (Either left) has a perfectly valid 
Monad instance for any type left (the only slightly difficult thing might 
be 'fail').

>
> (So the documentation for Control.Monad.Error, is mistaken, where
> at the top it says
>
>   Example type:
>       Either String a
>
> ... which should be
>
>       Either Error a
>
> ... ?

No, String is an instance of Error, so (Either String) is fine.

> Though I can't really be sure what the documentation is
> trying to say.)
>

In that case, have a look at the code, perhaps that is clearer. (And bug 
the maintainer(s) to improve the docs.)

>
> 	Donn Cave, donn at avvanta.com


More information about the Haskell-Cafe mailing list