AMP-corollary: `Alternative`/`MonadPlus`
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.
Trac metadata
| Trac field | Value |
|---|---|
| Version | |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |