Proposal: newtype for applicatives of monoids

Christopher Allen cma at bitemyapp.com
Mon Aug 3 17:30:24 UTC 2015


Might as well capture all of 'em in one go.

+1 w/ aforementioned mappend/mplus fix.


On Sun, Jul 26, 2015 at 10:34 PM, David Feuer <david.feuer at gmail.com> wrote:

> Sorry for the terrible title, but I think we should add something like the
> following to Data.Monoid (I already mentioned this in the discussion of a
> Monoid instance for ZipList).
>
> newtype Appl f m = Appl (f m)
>
> instance (Applicative f, Monoid m) => Monoid (Appl f m) where
>   mempty = Appl $ pure mempty
>   mplus (Appl x) (Appl y) = Appl $ liftA2 mplus x y
>
> It may be possible to use coercions to improve mplus; I haven't tried it.
>
> This type is the same as WrappedApplicative from semigroupoids, do it
> might be best just to give it that name.
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
>


-- 
Chris Allen
Currently working on http://haskellbook.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20150803/d6bfeaff/attachment.html>


More information about the Libraries mailing list