A Foldable
instance is likely to be some sort of container, and so is likely to be a Functor
as well. Indeed, this says
A
Foldable
type is also a container (although the class does not technically requireFunctor
, interestingFoldable
s are allFunctor
s).
So is there an example of a Foldable
which is not naturally a Functor
or a Traversable
? (which perhaps the Haskell wiki page missed :-) )
Here's a fully parametric example:
data Weird a = Weird a (a -> a)
instance Foldable Weird where
foldMap f (Weird a b) = f $ b a
Weird
is not a Functor
because a
occurs in a negative position.