
On Fri, Sep 24, 2010 at 07:09:56PM +0200, Milan Straka wrote:
I therefore propose to: a) add foldrWithKey and foldlWithKey to IntMap, make foldWithKey deprecated and synonymous for foldrWithKey.
Agree. Why not also add foldl and foldr to Map and IntMap, and deprecate fold?
b) add foldl and foldr to Set and IntSet, make fold deprecated and synonymous to foldr.
Agree.
c) add strict variants of left and right folds, namely Data.Map, Data.IntMap: foldlWithKey' foldrWithKey'
Agree. Again, why not foldl' and foldr' too?
Data.Set, Date.IntSet: foldl', foldr'
Agree.
Some issues: - should we really rename fold -> foldr?
Yes.
- should we really deprecate fold and foldWithKey?
Yes.
It could break a lot of code.
If that is a big worry, then it can be documented as deprecated with 7.2, have a deprecated pragmas with 7.4, and be removed with 7.6. That way, packages can remain -Wall clean while supporting a pair of GHC versions.
- adding foldl, foldr, foldl' and foldr' to Set and IntSet is going to cause a lot of trouble because of shadowing.
You mean name collisions with Prelude/Data.List? That's fine for these libraries; they already define things like map. Thanks Ian