Proposal: Make Semigroup and Monoid instances for Data.Functor.Compose

Ryan Scott ryan.gl.scott at gmail.com
Fri Jul 26 13:17:20 UTC 2019


Hi,

You may find the discussion at
https://mail.haskell.org/pipermail/libraries/2018-February/028571.html
interesting. The summarized version of that post is that
Data.Functor.Compose was originally brought over from the transformers
library, which adheres to a very Haskell98 mindset in its design. In
particular, the maintainer of transformers would likely not have added
the Semigroup or Monoid instances you propose, since they require the
FlexibleContexts language extension. This explains why there exists an
`instance (Eq1 f, Eq1 g, Eq a) => Eq (Compose f g a)` and not an
`instance Eq (f (g a)) => Eq (Compose f g a)`, among other things.

Of course, Data.Functor.Compose now lives in the base library, not
transformers, so we need not prescribe to the same design philosophy.
I don't feel too strongly about the issue, so if other people feel
like adding Semigroup/Monoid instances that require FlexibleContexts
is a good idea, I could get on board with that. What do others think?

Ryan S.


More information about the Libraries mailing list