Discussion: remove the Applicative superclass from Alternative

David Feuer david.feuer at gmail.com
Fri Nov 7 01:36:13 UTC 2014


Currently, Applicative is a superclass of Alternative. Unfortunately, the
*only* laws for Alternative are the monoid laws. Sensible sets of laws have
been proposed in the past, but unfortunately *none* of them cover all the
current important instances. Thus we have a rather awkward situation where
Alternative is a subclass of Applicative, but there's no real way to take
advantage of that fact. There are essentially no useful functions that
would end up with signatures that look like

p :: (Applicative f, Alternative f) => ...

I'm wondering, therefore, what people think of the idea of making
Alternative entirely independent—just a version of Monoid with a different
kind.

class Alternative f where
  empty :: f a
  (<|>) :: f a -> f a -> f a

A second option would be to go with a Functor superclass for Alternative;
that might save some typing over the independent Alternative, and it comes
with the free theorem

fmap f empty = empty
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141106/ab0043d1/attachment.html>


More information about the Libraries mailing list