[Haskell-cafe] MonadPlus or Alternative or ...?

Edward Kmett ekmett at gmail.com
Mon May 3 10:22:03 EDT 2010


On Sun, May 2, 2010 at 4:23 AM, Sebastian Fischer <
sebf at informatik.uni-kiel.de> wrote:

> Ideally, every MonadPlus instance would also be an Alternative instance and
> every Alternative instance would be an instance of Monoid. You may find it
> unfortunate that there are so many operations for the same thing but until
> the (Applicative/Monad) class hierarchy is refactored, we have to live with
> it.


Sadly there is at least one MonadPlus/Alternative and Monoid instance that
differs:

Maybe

The Monoid instance for Maybe is the lifting of a semigroup into a monoid by
adding an identity element, but unfortunately, it does so rather poorly as
there is no semigroup class that it can assume for its argument, and so it
lifts a monoid into a monoid, while avoiding the use of the underlying
definition for mempty. =/

So there is no path forward that doesn't change the meaning of existing
programs that makes the Alternative and Monoid instances agree on all
Applicatives.

-Edward Kmett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100503/02b60fa7/attachment.html


More information about the Haskell-Cafe mailing list