updateLookupWithKey bug? Was: Data.Map, Data.IntMap documentation (1611)

Iavor Diatchki iavor.diatchki at gmail.com
Fri Nov 2 16:38:17 EDT 2007


On 11/2/07, Christian Maeder <Christian.Maeder at dfki.de> wrote:
> Iavor Diatchki wrote:
> > Hi,
> > I have always wondered about the usefulness of the "withKey" functions
> > because the key is one of the arguments that the programmer is passing
> > anyway, so they already know its value.
> [...]
> > Does anybody have other uses of the "withKey" functions?
> > -Iavor
> The WithKey-variants are used where a new value is computed from an old
> one and when this function also needs to consider the key.
> At least filterWithKey and foldWithKey are very useful.

I was referring to the insert,update,adjust functions where the key is
already one of the arguments to the function.  For the various
traversals having a WithKey version makes sense.

> > PS: as for the bug, I would just fix it (i.e., send a patch)
> Which implementation do you consider buggy? IntMap or Map?
> (or may just document it as inconsistent)

I think that the two should have the same behaviour.   To me, the
implementation that returns the _old_ value seems more useful.


More information about the Libraries mailing list