Skip to content

Expand folding options for Sets and Maps

xref #2580 (closed) , http://www.haskell.org/pipermail/libraries/2008-September/010653.html , http://www.haskell.org/pipermail/libraries/2008-October/010782.html

I've attached a patch which expands on Evan's changes and propagates them to IntSet and IntMap.

Some (possibly controversial) changes of note :

  • Added foldr and foldl functions for the map types. This is redundant, but so is much of the interface. The argument to foldlWithKey has a strange type, (a -> key -> value -> a), that does not play nicely with flip and const. So I think its convenient to have foldl as well, and since we've got that why not throw foldr in too.
  • Specialized default implementations of foldl and foldr for Foldable class. This is perhaps better than exporting then from the map libraries. Data.Sequence does it this way, but the map libraries do not. If the API clutter is found to be unbearable then perhaps a major cleanup is in order, hiding all folds in the map/set modules and exporting them via Foldable.

Shall I also add strict versions?

Trac metadata
Trac field Value
Version 6.8.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries (other)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information