Opened 3 years ago

#157 new removal

AMP-corollary: `Alternative`/`MonadPlus`

Reported by: Herbert Valerio Riedel Owned by:
Priority: normal Milestone: Haskell 201x
Version: Keywords: Alternative, MonadPlus
Cc: Meta Owner: CLiC
State: discussion Section: Predefined Types/Classes
Related Tickets:


Haskell 2010 defines

class Monad m => MonadPlus m where
  mzero :: m a
  mplus :: m a -> m a -> m a

instance MonadPlus []
instance MonadPlus Maybe

With AMP, a generalisation to Applicative becomes obvious, which is widely known as Applicative:

class Applicative f => Alternative f where
  empty :: f a
  (<|>) :: f a -> f a -> f a
  some :: f a -> f [a]
  some = ...
  many :: f a -> f [a]
  many = ...

instance Alternative []
instance Alternative Maybe

This makes MonadPlus mostly redundant, as mzero = empty and mplus = (<|>) is used in most cases.

Therefore, it may be sensible to remove MonadPlus from the library report and add Alternative instead. Haskell implementations may still choose to provide a legacy MonadPlus in their standard library.

Change History (0)

Note: See TracTickets for help on using tickets.