[Haskell-cafe] instance Monad (Either String) in Prelude or
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
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
> >> Haskell.
> >> There is a spurious restraint that the Left value in your Either be a
> >> of some Error class, which was brought about by the deletion of
> >> 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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe