I admit that this question is a bit unspecific, but I was wondering why I never stumbled upon a type class for monoids on functors in Haskell. Did I just miss it, is there good reason for this absence or is it entirely due to historic causes? IMHO, the following inheritance chart looks a bit odd without a top right corner:
Functor
|
V
Applicative ––> Alternative
| |
V V
Monad ––> MonadPlus
One key factor to think about here is, "What does the arrow from Functor
really mean?" If there are no axioms that unify Functor
with FunctorPlus
then you might as well just define instance Monoid (F t) where ...
and be done with it. So what axioms are you looking for -- just fmap f fempty = fempty
or also fmap f x <|> fmap f y == fmap f (x <|> y)
...?
Another key factor will be the dearth of interesting structures which are functors but not applicatives. There's probably an argument having to do with generic-programming (metaprogramming the deriving
keyword) where everything is a sum of products and therefore we can derive Applicative
for anything of kind * -> *
, but I don't know the details. The only value FunctorPlus
could possibly have is "doing the same thing that Alternative does for Functors which are not Applicative," and so if that set is really small then there's obviously not much value added.
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