Proposal: keep Data.Map.foldWithKey

Ross Paterson ross at
Fri Dec 17 00:04:19 CET 2010

On Wed, Dec 15, 2010 at 03:38:37PM +0100, Johan Tibell wrote:
> My vote is "no", there are already too many fold variants in Data.Map. We have
> {left,right} x {non-strict,strict} x {with key, without key} = 8
> combinations together.
> Adding back the "directionless" version would mean another 4 versions
> of we want symmetry. This in a module that already has 150 functions.
> We need to do something about the large amount of both API (i.e.
> usability tax) and implementation (maintainer overhead) duplication in
> the containers library.

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.

More information about the Libraries mailing list