Proposal: Add Alternative adapter to Data.Monoid
Edward Kmett
ekmett at gmail.com
Thu Oct 30 16:55:56 UTC 2014
+1 from me.
I'll happily delete my versions in `reducers` and `monoids`.
On Thu, Oct 30, 2014 at 12:46 PM, David Feuer <david.feuer at gmail.com> wrote:
> I found myself needing this type in my current overhaul of Data.Foldable,
> but it seems to be generally useful:
>
> newtype Alt f a = Alt { getAlt :: f a } deriving
> (Eq,Ord,Show,Read,Typeable,Data,Generic,Num,Real,
> Floating, Fractional, RealFrac, RealFloat, Integral, Enum,
> Bounded,Ix,Functor,Foldable,Traversable,Applicative,
> Alternative,Monad,MonadPlus,MonadFix, IsString, IsList)
> -- The laundry list of derived instances is as recommended by Edward
> Kmett, who would probably want more added if someone can think of more.
> Some of them would, of course, need to be derived in other modules. The key
> instance is this:
>
> instance Alternative t => Monoid (Alt t a) where
> mempty = Alt empty
> (Alt m) `mappend` (Alt n) = Alt (m <|> n)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141030/55d5d4cd/attachment.html>
More information about the Libraries
mailing list