From: Simon Marlow Date: Fri, 13 Aug 2010 15:31:42 +0000 (+0000) Subject: fix hashInteger to be the same as fromIntegral, and document it (#4108) X-Git-Tag: ghc-darcs-git-switchover~11 X-Git-Url: http://git.haskell.org/packages/integer-gmp.git/commitdiff_plain/72f33619607194132bfd16fa3afcbf8a814cd0e1 fix hashInteger to be the same as fromIntegral, and document it (#4108) --- diff --git a/GHC/Integer.lhs b/GHC/Integer.lhs index 1e731a6..0f06d9a 100644 --- a/GHC/Integer.lhs +++ b/GHC/Integer.lhs @@ -54,8 +54,7 @@ import GHC.Prim ( quotInt#, remInt#, negateInt#, (==#), (/=#), (<=#), (>=#), (<#), (>#), (*#), (-#), (+#), mulIntMayOflo#, addIntC#, subIntC#, - and#, or#, xor#, - indexIntArray#, + and#, or#, xor# ) import GHC.Integer.GMP.Internals ( @@ -539,10 +538,12 @@ shiftRInteger (J# s d) i = case fdivQ2ExpInteger# s d i of \begin{code} -- This is used by hashUnique +-- | hashInteger returns the same value as 'fromIntegral', although in +-- unboxed form. It might be a reasonable hash function for 'Integer', +-- given a suitable distribution of 'Integer' values. + hashInteger :: Integer -> Int# -hashInteger (S# i) = i -hashInteger (J# s d) = if s ==# 0# - then 0# - else indexIntArray# d 0# +hashInteger = toInt# + \end{code}