Data.HashTable weirdness

Kirsten Chevalier krc at cs.berkeley.edu
Sat Nov 8 12:23:40 EST 2003


I have some code that uses the Data.HashTable module (passing around a 
hash table as part of the state in a state monad). I had a function which
took a key and value and added it to the hash table, using the HashTable.insert
function. When I changed this function to delete the key from the table first,
using HashTable.delete, the behavior of the function changed. That is, at
first, looking up a key in the table gave a wrong result (seemingly, a "stale"
value), but after changing the function to delete the key before adding it,
my program behaved correctly.

This seems strange to me. According to my understanding of how a hash table
should work, inserting a key in the table should overwrite the previous value
for that key, so inserting a key should be equivalent to deleting it and then
inserting it. But clearly that's not the case here. Can anyone explain this?

--
Kirsten Chevalier * krc at cs.berkeley.edu * Often in error, never in doubt
"The information superhighway showed the average person what some nerd thinks
about Star Trek."--Homer Simpson
http://www.cs.berkeley.edu/~krc/


More information about the Glasgow-haskell-users mailing list