X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FUnique.hs;h=ab3d64718d6f7e8d3b648d316bbf994c6eb35fbd;hb=487b9d4571a847ee0273b4627aaa135c46a51b8d;hp=38c8e483bb59dbce59de36f0f79309e256e5bdac;hpb=4a47541267395ee2a0cb517021d8aba56b73c905;p=ghc-base.git diff --git a/Data/Unique.hs b/Data/Unique.hs index 38c8e48..ab3d647 100644 --- a/Data/Unique.hs +++ b/Data/Unique.hs @@ -27,11 +27,16 @@ import System.IO.Unsafe (unsafePerformIO) import GHC.Base import GHC.Num import GHC.Conc +import Data.Typeable #endif -- | An abstract unique object. Objects of type 'Unique' may be -- compared for equality and ordering and hashed into 'Int'. -newtype Unique = Unique Integer deriving (Eq,Ord) +newtype Unique = Unique Integer deriving (Eq,Ord +#ifdef __GLASGOW_HASKELL__ + ,Typeable +#endif + ) uniqSource :: TVar Integer uniqSource = unsafePerformIO (newTVarIO 0) @@ -45,7 +50,7 @@ newUnique :: IO Unique newUnique = atomically $ do val <- readTVar uniqSource let next = val+1 - writeTVar uniqSource $! val + 1 + writeTVar uniqSource $! next return (Unique next) -- SDM (18/3/2010): changed from MVar to STM. This fixes