base package (Was: GHC 7.8 release?)
Ian Lynagh
ian at well-typed.com
Wed Feb 20 18:12:10 CET 2013
On Fri, Feb 15, 2013 at 02:45:19PM +0000, Simon Marlow wrote:
>
> Remember that fingerprinting is not hashing. For fingerprinting we
> need to have a realistic expectation of no collisions. I don't
> think FNV is suitable.
>
> I'm sure it would be possible to replace the C md5 code with some
> Haskell. Performance *is* important here though - Typeable is in
> the inner loop of certain generic programming libraries, like SYB.
We currently just compare
hash(str)
for equality, right? Could we instead compare
(hash str, str)
? That would be even more correct, even if a bad/cheap hash function is
used, and would only be slower for the case where the types match
(unless you're unlucky and get a hash collision).
In fact, we may be able to arrange it so that in the equal case the
strings are normally exactly the same string, so we can do a cheap
pointer equality test (like ByteString already does) to make the equal
case fast too (falling back to actually checking the strings are equal,
if they aren't the same string).
Thanks
Ian
More information about the Glasgow-haskell-users
mailing list