[Haskell-cafe] FiniteMap-like module for unordered keys?

Remi Turk rturk at science.uva.nl
Tue Nov 9 17:25:36 EST 2004


On Mon, Nov 08, 2004 at 04:40:58PM +0000, Graham Klyne wrote:
> Is there a module that provides functionality similar to that of 
> Data.FiniteMap for keys that do not have a defined ordering relation?
Not as far as I know. (Unless you're content with the standard
List library's lookup/delete/union/etc)

I don't know if it'd help you, but I'd like to see a FiniteMap
which accepts an explicit compare-function instead of requesting
it's key-type to be an instance of Ord. One may e.g. want
complex numbers in a finitemap (without having to make Complex an
instance of Ord), which shouldn't be a problem as an adhoc
ordering on Complex is rather trivial to make...

> (I looked at Data.HashTable, but I couldn't figure why it needs to be 
> implemented in the IO monad, except to optimize the internal 
> implementation.  Also, it's not clear to me how it behaves when a key is 
> inserted that already exists.)
A hash-table becomes rather useless without mutable state AFAICS.
Without it, one might almost just as well use a list of pairs...
Actually, some kind of freezeHashTable may be useful, and
a HashTable in the ST monad is definitely useful: I guess patches
are welcome..

Cheers,
Remi

P.S. If enough people promise to eternally like me for it I might
actually do it myself ;)

-- 
Nobody can be exactly like me. Even I have trouble doing it.


More information about the Haskell-Cafe mailing list