Proposal: Add a few extra members to Foldable and Traversable classes

Edward Kmett ekmett at gmail.com
Sun Sep 21 15:37:12 UTC 2014


Yes.

I really do consider foldMap to be the canonical form, and both foldr and
foldl to be definable things in terms of it, but for historical reasons
foldMap has a default definition in terms of foldr.

-Edward

On Sun, Sep 21, 2014 at 11:21 AM, Sjoerd Visscher <sjoerd at w3future.com>
wrote:

>
> foldMap is used to provide a 'natural' fold regardless of associativity.
>
> foldMap and foldr are are mutually definable, by using Endo to get foldr
> from foldMap, or just accepting a right associated monoidal reduction.
>
> This is why foldr or foldMap are the minimal definitions.
>
> However, you can't build foldr in terms of foldl with the right behavior
> on infinite containers, so foldl is _not_ a viable minimal definition for
> Foldable in a world where you can have infinitely big things to fold!
>
>
> Wouldn’t it be the other way around for infinite snoc-lists?
>
> Sjoerd
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140921/7abf1288/attachment.html>


More information about the Libraries mailing list