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

Iavor Diatchki iavor.diatchki at gmail.com
Fri Nov 2 12:43:41 EDT 2007

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.  The only situation that I can
think of where that might not be the case is if the equality relation
on the keys is actually an equivalence relation, so the key in the map
might be different from the key that was passed by the programmer even
though they are "equal", and the distinction between the two keys is
important.   I would be a bit suspect of code that relies on that
though... Does anybody have other uses of the "withKey" functions?

PS: as for the bug, I would just fix it (i.e., send a patch)

On 11/2/07, Adrian Hey <ahey at iee.org> wrote:
> Andriy Palamarchuk wrote:
> > Adrian, question whether to deprecate
> > updateLookupWithKey  is worth discussing, but we need
> > to fix the function anyway.
> I would say just document the code as it is, warts and all.
> Don't change the functions because maybe someone is using them
> (though I suspect this is not the case).
> But also add a DEPRECATE pragma to discourage further use.
> Maybe do this for both IntMap and Map, because even if they were
> consistent, I don't think they're very useful. An API that clearly
> separates the process of searching for the key from whatever you want
> to do when it's found (or not) is so much more flexible and easy to
> understand IMHO.
> BTW, the way I did this should also work for IntMap tries too AFAICT,
> but I'm not sure it would offer any performance advantage over a
> repeated lookup in this case. So maybe keep them for IntMap?
> My 2p..
> Regards
> --
> Adrian Hey
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries

More information about the Libraries mailing list