unique-0.0.1: Fully concurrent unique identifiers
Safe HaskellTrustworthy
LanguageHaskell2010

Control.Concurrent.Unique

Description

An abstract interface to a concurrent unique symbol generator.

Unlike Data.Unique from base the values are not a member of Ord. However, there is no global bottleneck.

Synopsis

Documentation

data Unique Source #

Unique identifiers are created by creating heap objects in kind # that can be compared for value equality and then hashing them using their initial allocation address.

>>> x <- newUnique
>>> y <- newUnique
>>> z <- newUnique
>>> [x == x, y == y, z == z]
[True,True,True]
>>> [x == y, y == z, z == x]
[False,False,False]

The hashes could be same, in theory, but in practice they are different as well.

>>> [ hash x == hash x, hash y == hash y, hash z == hash z]
[True,True,True]
>>> [ hash x == hash y, hash y == hash z, hash z == hash x]
[False,False,False]

Instances

Instances details
Eq Unique Source # 
Instance details

Defined in Control.Concurrent.Unique

Methods

(==) :: Unique -> Unique -> Bool #

(/=) :: Unique -> Unique -> Bool #

Hashable Unique Source # 
Instance details

Defined in Control.Concurrent.Unique

Methods

hashWithSalt :: Int -> Unique -> Int #

hash :: Unique -> Int #

newUnique :: IO Unique Source #

Allocate a new Unique value. The value returned will not compare equal to any other value of type Unique returned by previous calls to newUnique. There is no limit on the number of times newUnique may be called.