Containers and folds
fox at ucw.cz
Fri Sep 24 13:25:27 EDT 2010
sorry for breaking the rules again and not making myself clear.
I would like to hear other opinions on the folds in the containers
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 I am thinking about: a) add left/right folds, b) add strict
What do you think about:
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'
- should fold be really renamed to foldr? Maybe we could clarify
that fold and foldWithKey are right folds and add only
foldl and foldlWithKey.
- should fold really be deprecated? 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.
Thanks for any opinions.
More information about the Libraries