Data.HashTable and duplicate keys

George Russell ger at informatik.uni-bremen.de
Tue Sep 28 09:20:14 EDT 2004


Simon Marlow wrote (snipped):
> Making insert do delete+insert is pretty inefficient if you know that
> the key isn't in the table.  Providing update (==delete+insert) seems a
> reasonable solution, no?

You could provide a general function
    generalUpdate :: HashTable key value -> key
       -> (Maybe value -> IO (Maybe value,b)) -> IO b
and then start from there.  This would mean you could to lookup+delete+insert
in just *one* operation (rather than 3).

I really don't see the point of having multiple values for the same key; it's just
confusing.  If that's really what users want they can use a HashTable key [value]
rather than a HashTable key value.


More information about the Libraries mailing list