Proposal: keep Data.Map.foldWithKey

Christian Maeder Christian.Maeder at
Wed Dec 15 10:57:30 CET 2010

Am 14.12.2010 18:42, schrieb Ian Lynagh:
> On Tue, Dec 14, 2010 at 01:28:14PM +0100, Christian Maeder wrote:
>> I've now created a proper library proposal to keep Data.Map.foldWithKey.
> In the ticket you say:
>     [keep] Data.Map.foldWithKey as the aim to finally remove this function
>     is bad as long as Data.IntMap.foldWithKey is the primary folding
>     function for the specialized maps.
> but why is keeping foldWithKey the right answer, rather than adding
> fold{l,r}WithKey to Data.IntMap (and removing foldWithKey from it)?

It is the right answer as long as fold{l,r}WithKey are missing in

I'm in favour of adding fold{l,r}WithKey to Data.IntMap and then
deprecating both foldWithKey functions in one go!

In fact, this should have been happened. (Yet, there is no library
proposal for this.)

Maybe it is even a good idea to add foldr and foldl functions to
Data.{Set,IntSet,Map,IntMap} first and deprecate also the plain fold
functions. And maybe toList (and assocs) should be deprecated in favour
of toAscList, toDescList.

I simply dislike the destroyed symmetry in the 4 container modules and
deprecating a single function.


> Thanks
> Ian

More information about the Libraries mailing list