Sum defined in base 4.7.0.2 doesn't have Functor instance. Why?
For example types defined in semigroups package have Functor, Applicative and Monad on e.g. Min, which behave likeIdentity` - makes sense to me.
I believe the main reason these are not Functor instances is that you have not yet submitted a code review to make them so. You can file a ticket on Trac, then submit a code review on Phabricator. The preferred Phabricator workflow (using Arcanist), along with other details, can be found here.
While you're doing that, you should probably also make them instances of Applicative, and Monad. You should also add Foldable and Traversable instances for them in Data.Foldable and Data.Traversable, respectively.
If you want me to guess why nobody else did this:
While Sum and Product can hold things of any type, the Monoid instances only make sense for Num instances. The type of fmap thus feels a bit oddly general. This, however, is not really a good reason not to make them Functor instances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With