packages feed

MicroHs-0.17.4.0 / lib / Data / Unique.hs

module Data.Unique(  Unique,  newUnique,  hashUnique,  ) whereimport Data.IORefimport System.IO.Unsafenewtype Unique = Unique Integer deriving (Eq, Ord)uniqSource :: IORef IntegeruniqSource = unsafePerformIO (newIORef 0)newUnique :: IO UniquenewUnique = do  r <- atomicModifyIORef' uniqSource $ \x -> let z = x+1 in (z,z)  return (Unique r)hashUnique :: Unique -> InthashUnique (Unique i) = fromInteger i