Foldable class, generalised to use arrows in categories other than
->. This changes the interface somewhat – in particular,
foldr relies on currying and hence can't really be expressed in
a category without exponential objects; however the monoidal folds
come out quite nicely. (Of course, it's debatable how much sense the
Hask-
Monoid class even makes in other categories.)
Unlike with the
Functor classes, there is no derived instance
Foldable f => Foldable f (->) (->): in
this case, it would prevent some genarality. See below for how to
define such an instance manually.