Proposal: Add Applicative (and Monoid) instances in GHC.Generics

Edward Kmett ekmett at gmail.com
Wed Feb 21 19:56:20 UTC 2018


+1 for adding the instances.

I'm fairly neutral on the helpers.

-Edward

On Wed, Feb 21, 2018 at 1:16 PM, Ryan Scott <ryan.gl.scott at gmail.com> wrote:

> In response to each of your proposals:
>
> > 1. Add an instance (Monoid c => Applicative (K1 i c))
>
> This seems like a no-brainer to me. +1
>
> > 2. Add helpers
> >
> >          gmempty :: (Generic a, Applicative (Rep a)) => a
> >          gmempty = to (pure ())
> >
> >          gmappend :: (Generic a, Applicative (Rep a)) => a -> a -> a
> >          gmappend a b = to (from a <*> from b)
> >
> >          -- also gpure, gap for generic Applicative
>
> I'm weakly -1 on this. I don't think GHC.Generics should be a place
> where we collect combinators for generically implementing various type
> class methods. I'd prefer that these be left to downstream libraries,
> especially since they're usually extremely straightforward to
> implement and wouldn't cross the Fairbairn threshold for me.
>
> > 3. Add Monoid instances
>
> I think I support this idea. But just to be sure we're on the same
> page: can you say which instances in particular you're adding, and how
> you'd implement them?
>
> Ryan S.
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20180221/01faf495/attachment.html>


More information about the Libraries mailing list