Proposal: keep Data.Map.foldWithKey

Max Bolingbroke batterseapower at
Fri Dec 17 08:45:47 CET 2010

On 16 December 2010 23:04, Ross Paterson <ross at> wrote:
> Well, once you have
>  withKeys :: Map k a -> Map k (k,a)
>  withKeys = mapWithKey (,)
> and the Foldable instance, all those fold variants are redundant, as are
> all the WithKey variants.

Not as efficient though, because using withKeys and then folding
requires two traversals and allocates an intermediate map compared to
just folding withKey.

More broadly, I don't really see the argument for removing stuff from
Data.Map. The code is already written and the core implementation of
Data.Map is unlikely to change very much since Milan already confirmed
it's almost optimal. So there doesn't seem to be a big maintainer
burden to keeping the current interface. Is there some reason that
maintaing Data.Map is more difficult than I expect?

There may be a burden to the new user of Data.Map if they are
overwhelmed by the sheer number of different functions (though this is
not a problem I had personally), but that could be solved by having a
Data.Map.Simple module or just reorganising the Haddock docs so the
most commonly used functions appear first on the page. Is this not a
better approach than breaking existing code by removing functionality?


More information about the Libraries mailing list