projects
/
ghc-base.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add numSparks :: IO Int (#4167)
[ghc-base.git]
/
Data
/
Unique.hs
diff --git
a/Data/Unique.hs
b/Data/Unique.hs
index
38c8e48
..
ab3d647
100644
(file)
--- 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 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'.
#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)
uniqSource :: TVar Integer
uniqSource = unsafePerformIO (newTVarIO 0)
@@
-45,7
+50,7
@@
newUnique :: IO Unique
newUnique = atomically $ do
val <- readTVar uniqSource
let next = val+1
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
return (Unique next)
-- SDM (18/3/2010): changed from MVar to STM. This fixes