
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. 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?
-Iavor
PS: as for the bug, I would just fix it (i.e., send a patch)
On 11/2/07, Adrian Hey
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@haskell.org http://www.haskell.org/mailman/listinfo/libraries