[Haskell-cafe] Foldable for (,)

Jonathon Delgado voldermort at hotmail.com
Thu May 4 09:30:46 UTC 2017


Ay, there's the rub. Traversable over (,) can be expressed as a fold over a single element, but that doesn't mean it should be. All you want in this case is the effect.

From: Nickolay Kudasov <nickolay.kudasov at gmail.com>
Sent: 04 May 2017 08:16Subject: Re: [Haskell-cafe] Foldable for (,)
....
It turns out that by using Const applicative functor you can use traverse to perform foldMap! Thus every Traversable is trivially a Foldable (see foldMapDefault).
Similarly, every Traversable is trivially a Functor if you use Identity applicative functor (see fmapDefault).
This is why Traversable has those Functor and Foldable constraints, not because it relies on fmap or foldMap.


More information about the Haskell-Cafe mailing list