We could add a newtype for this in Data.Monoid.

newtype Appl f a = Appl (f a)
instance (Applicative f, Monoid a) => Monoid (Appl f a) where
  mempty = Appl $ pure mempty
  mplus (Appl x) (Appl y) = Appl $ liftA2 mplus x y

On Jul 25, 2015 4:50 PM, "Christopher Allen" <cma@bitemyapp.com> wrote:
http://hackage.haskell.org/package/base-4.8.1.0/docs/Control-Applicative.html#t:ZipList

There's a Monoid that matches what the Applicative for ZipList does that seems to be missing.

instance Monoid a => Monoid (ZipList a) where
  mempty  = pure mempty
  mappend = liftA2 mappend

It's been brought up before:

https://mail.haskell.org/pipermail/haskell-cafe/2009-October/067861.html

Not only is it useful when it's the Monoid you want, but it serves an educational purpose for highlighting the relationship between Monoid and Applicative as well.

Are there any good reasons not to have it?

I'd like to limit discussion to two weeks.


_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries