[Fwd: updateLookupWithKey confusion]

Adrian Hey ahey at iee.org
Sat Mar 31 09:29:01 EDT 2007

Hello Folks,

Jean-Philippe suggests I put this question to
the libraries list. Any thoughts?

-------- Original Message --------
Subject: updateLookupWithKey confusion
Date: Mon, 26 Mar 2007 08:18:47 +0100
From: Adrian Hey <ahey at iee.org>
To: Jean-Philippe Bernardy <jeanphilippe.bernardy at gmail.com>

Hello Jean-Philippe,

There seems to be some confusion over this between
Haddock documentation and the two implementations
in Data.Map and Data.Map.AVL.

Is the 'looked up' value supposed to be the value
bound to the corresponding key in the map before
or after the update? The behaviour isn't specified
in the Haddock of either version.

In Data.Map implementation you could get the value
present before or after the update (depending on
whether or not the association is deleted).
Surely that's wrong?

In Data.Map.AVL you consistently get the value
present before the update occurs, but I would
have thought it be more useful to get the value
after the update occurs (if any).

Anyway, I think the behaviour needs specifiying
and whichever implementation(s) is not consistent
with that spec needs modifying. I'm working on
Data.Map.AVL at the moment so I'll fix it if
it's wrong (and make it more efficient too).

Also, why don't we have a plain updateLookup?
(without key), like we do for other funcions.

Adrian Hey

More information about the Libraries mailing list