Hash functions

Simon Marlow simonmar@microsoft.com
Wed, 20 Aug 2003 10:23:38 +0100


=20
> Many thanks for Data.HashTable, which I am about to use. =20
> Unfortunately
> I seem to need an unseemly hack because the key I want,=20
> namely ThreadId's,
> don't have a hash function defined, and defining one requires=20
> me to muck
> around with GHC internal functions.  Could some more hash functions be
> provided?
>=20
> The logical method would be to have
>=20
>     class HashKey key where
>        hash :: key -> Int32
>=20
> 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