An example of a Foldable which is not a Functor (or not Traversable)?

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.

Leave a Comment