It's not so much that it's *necessary* as that it's *possible*. The existence of two functions in Data.Traversable explains both of the superclasses of Traversable:

fmapDefault :: Traversable t => (a -> b) -> t a -> t b

foldMapDefault :: (Traversable t, Monoid m) => (a -> m) -> t a -> m

Each of these is written using only traverse, and they can be used to define fmap and foldMap for types when you've written traverse.

Hint: Consider traversing using the following applicative functors:

newtype Const a b = Const a
instance Monoid a => Applicative (Const a)

newtype Identity a = Identity a
instance Applicative Identity

On Feb 5, 2016 1:45 PM, "David Banas" <capn.freako@gmail.com> wrote:
Hi all,

I don't understand why Foldable is a necessary super-class of Traversable, and I suspect that the Applicative/Monoid duality, which I've just begun discovering in the literature, has something to do with why that is so.

Can anyone give me a hint, without giving me the answer?

Thanks!
-db


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe