Data.HashTable and duplicate keys
Einar Karttunen
ekarttun at cs.helsinki.fi
Mon Sep 27 10:52:02 EDT 2004
Hello
I recently noticed that Data.HashTable silently
accepts duplicate keys and keeps all the values.
This is very counterintuitive from the interface
and makes updating a hashtable quite tedious
(lookup + delete + insert).
Mentioning the feature in the documentation and
providing an update function would be very nice.
e.g. update :: HashTable k v -> k -> (v -> v) -> IO Bool or
update :: HashTable k v -> k -> (v -> (v, w)) -> IO (Maybe w)
with the result marking whether the key was present
in the hashtable.
On the other hand, if it is a bug I hope it will
be solved quickly. The behaviour can be demonstrated
with
main = do ht <- new (==) hashInt
insert ht 1 1
insert ht 1 2
toList ht >>= print
- Einar Karttunen
More information about the Libraries
mailing list