Containers and folds

Johan Tibell johan.tibell at
Fri Sep 24 16:20:56 EDT 2010

On Fri, Sep 24, 2010 at 7:09 PM, Milan Straka <fox at> wrote:

> There are two thinks to sort out: a) add left/right folds, b) add strict
> folds.
> I therefore propose to:
> a) add foldrWithKey and foldlWithKey to IntMap, make foldWithKey
>   deprecated and synonymous for foldrWithKey.


> b) add foldl and foldr to Set and IntSet, make fold deprecated
>   and synonymous to foldr.


> c) add strict variants of left and right folds, namely
>  Data.Map, Data.IntMap: foldlWithKey' foldrWithKey'
>  Data.Set, Date.IntSet: foldl', foldr'


> Some issues:
> - should we really rename fold -> foldr? Maybe we could cla
>  that fold and foldWithKey are right folds and add only
>  foldl and foldlWithKey.

I'd prefer to rename. We need to keep the old version around for a long time
though, with a DEPRECATED pragma encouraging people to upgrade.

> - should we really deprecate fold and foldWithKey? It could break
>  a lot of code.

I think so. Give people a year or so to move over.

> - adding foldl, foldr, foldl' and foldr' to Set and IntSet is going to
>  cause a lot of trouble because of shadowing. Maybe some better name?
>  On the other hand, these are the "right" names.

 I think we should go with the "right" names. I think many modules already
import these modules qualified due to other name clashes (as they should).
We should encourage proper use of namespaces to resolve name clashes.
Breakages can be resolved by putting a upper version bound on containers in
the .cabal file of the broken library.

-- Johan
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Libraries mailing list