RE: Hash functions

2003-08-20 Thread Simon Marlow
 
> Many thanks for Data.HashTable, which I am about to use.  
> Unfortunately
> I seem to need an unseemly hack because the key I want, 
> namely ThreadId's,
> don't have a hash function defined, and defining one requires 
> me to muck
> around with GHC internal functions.  Could some more hash functions be
> provided?
> 
> The logical method would be to have
> 
> class HashKey key where
>hash :: key -> Int32
> 
> and define it for as many types as possible.

I think the reason I didn't do this was because the choice of a hash
function usually depends on more than just the type of the data you want
to hash.  For example, there are lots of hash functions over Int, but
you'll want to pick one that works well for the distribution of values
you have.

There really ought to be a way to get an Int from a ThreadId, though.

Cheers,
Simon
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Hash functions

2003-08-19 Thread George Russell
Many thanks for Data.HashTable, which I am about to use.  Unfortunately
I seem to need an unseemly hack because the key I want, namely ThreadId's,
don't have a hash function defined, and defining one requires me to muck
around with GHC internal functions.  Could some more hash functions be
provided?
The logical method would be to have

   class HashKey key where
  hash :: key -> Int32
and define it for as many types as possible.

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users