
28 Sep
2004
28 Sep
'04
9:20 a.m.
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.