X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FUnique.hs;h=6f8c24f0e3dc3da0f641904d3307f68c7903e1ad;hb=fdb4cee6ff91b59915eedba0afa3285681cbcab7;hp=a5a96f62b214ec8d32582e1b87e46e6aa1a646bb;hpb=263380d225508c7f3d4afc74fed427a08d2e132d;p=ghc-base.git diff --git a/Data/Unique.hs b/Data/Unique.hs index a5a96f6..6f8c24f 100644 --- a/Data/Unique.hs +++ b/Data/Unique.hs @@ -14,19 +14,19 @@ module Data.Unique ( -- * Unique objects - Unique, -- instance (Eq, Ord) - newUnique, -- :: IO Unique - hashUnique -- :: Unique -> Int + Unique, -- instance (Eq, Ord) + newUnique, -- :: IO Unique + hashUnique -- :: Unique -> Int ) where import Prelude -import Control.Concurrent +import Control.Concurrent.MVar import System.IO.Unsafe (unsafePerformIO) #ifdef __GLASGOW_HASKELL__ import GHC.Base -import GHC.Num ( Integer(..) ) +import GHC.Num #endif -- | An abstract unique object. Objects of type 'Unique' may be @@ -52,10 +52,8 @@ newUnique = do -- same value, although in practice this is unlikely. The 'Int' -- returned makes a good hash key. hashUnique :: Unique -> Int -#ifdef __GLASGOW_HASKELL__ -hashUnique (Unique (S# i)) = I# i -hashUnique (Unique (J# s d)) | s ==# 0# = 0 - | otherwise = I# (indexIntArray# d 0#) +#if defined(__GLASGOW_HASKELL__) +hashUnique (Unique i) = I# (hashInteger i) #else -hashUnique (Unique u) = u `mod` (fromIntegral (maxBound :: Int) + 1) +hashUnique (Unique u) = fromInteger (u `mod` (toInteger (maxBound :: Int) + 1)) #endif