Containers and folds

Don Stewart dons at galois.com
Fri Sep 24 13:13:48 EDT 2010


Milan, where's the libraries ticket for these extensions?

Please follow the libraries submission process:

    http://www.haskell.org/haskellwiki/Library_submissions#Creating_a_proposal    

Do *not* just push patches to containers without review!

Please provide a ticket, and *the actual patch* you wish to push.

fox:
> Hi,
> 
> the Set, and IntSet have one 'fold' that does not specify order of
> folding (but in fact are right folds).
> 
> Map and IntMap have 'fold' and 'foldWithKey' which is a right fold
> (and documented as such).
> 
> Recently foldrWithKey and foldlWithKey was added to Data.Map
> (foldWithKey is deprecated and a synonymous for foldrWithKey).
> 
> 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.
> - should we really deprecate fold and foldWithKey? It could break
>   a lot of code.
> - 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.
> 
> Discussion period: three weeks (because of ICFP).
> Discussion ends: 15th Oct.
> 
> Milan
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries


More information about the Libraries mailing list