Add Alternative wrapper to Data.Monoid
As discussed on the libraries list,
-- | Monoid under @<|>@.
newtype Alt f a = Alt {getAlt :: f a}
deriving (Generic, Generic1, Read, Show, Eq, Ord, Num, Enum,
Monad, MonadPlus, Applicative, Alternative, Functor)
instance forall f a . Alternative f => Monoid (Alt f a) where
mempty = Alt empty
mappend = coerce ((<|>) :: f a -> f a -> f a)
The documentation for Data.Monoid.First
and Data.Monoid.Last
should also be expanded to explain that First a
is isomorphic to Alt Maybe a
and Last a
is isomorphic to Dual (Alt Maybe a)
.
Trac metadata
Trac field | Value |
---|---|
Version | 7.9 |
Type | Task |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Core Libraries |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | core-libraries-committee@haskell.org |
Operating system | |
Architecture |