[Haskell-cafe] instance Monad (Either String) in Prelude or Data.Either?

Edward Kmett ekmett at gmail.com
Sat Sep 12 19:34:36 EDT 2009

You could, but then you need overlapping instances to define the one in
-Edward Kmett

On Sat, Sep 12, 2009 at 4:26 PM, Henning Thielemann <
lemming at henning-thielemann.de> wrote:

> Evan Laforge schrieb:
> > On Fri, Sep 11, 2009 at 6:10 AM, Edward Kmett <ekmett at gmail.com> wrote:
> >> Unfortunately, the instance of Monad for Either a is somewhat misguided
> in
> >> Haskell.
> >>
> >> There is a spurious restraint that the Left value in your Either be a
> member
> >> of some Error class, which was brought about by the deletion of
> MonadZero
> >> from Haskell 98 (as part of the elimination of failure free patterns,
> and an
> >> attempted simplification of the language).
> >
> > I just tried it, and my own instance for Monad (Either String) (all
> > I'm really interested in anyway) can coexist with the one for Error e
> > => Monad (Either e).  But indeed, with the presence of fail, you can't
> > write the general Monad (Either e) which "should" work.  And it does
> > require FlexibleInstances.  I suppose as long as flexible instances
> > aren't standard then even the String instance can't go in the Prelude.
> Are you sure, that the instance cannot be defined in Haskell 98 using a
> helper type class for the Char datatype?
>  http://www.haskell.org/haskellwiki/List_instance
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090912/7a1ac6ad/attachment.html

More information about the Haskell-Cafe mailing list