3 Answers
3

That's the general recipe for glomming a bunch of stuff together. It was one of the use cases which convinced me that it was worth separating Applicative from Monad. I needed stuff like generalized elem

elem :: Eq x => x -> Term x -> Bool

to do occur-checking for a Traversable Term parametrized by the representation of free variables. I kept changing the representation of Term and I was fed up modifying a zillion traversal functions, some of which were doing accumulations, rather than effectful mapping. I was glad to find an abstraction which covered both.

Doesn't foldMap id produce the same result with less constraints (Foldable instead of Traversable)?
–
Petr PudlákAug 27 '12 at 7:01

1

Indeed, that's why Foldable exists. However, it's rather useful that everything Traversable is Foldable, with the above being the construction of foldMapDefault. Plug: SHE supports DefaultSuperclassInstances, so that everything Traversable is by silent default made Foldable in that way.
–
pigworkerSep 6 '12 at 8:56

It's useful when you have a function or data structure that works for all (Applicative) Functors, and wish to reuse it in a degenerate sense. It's analogous to passing in const or id to functions that work given arbitrary functions.

Van Laarhoven lenses are defined in terms of arbitrary Functors, and use Const to derive a field accessor (and the equally trivial Identity to derive a field updater).

Traversable types, as pigworker mentions, are another example of this.