base-4.18.1.0: Basic libraries

Copyright | (c) The University of Glasgow 2001
License | BSD-style (see the file libraries/base/LICENSE)
Maintainer | libraries@haskell.org
Stability | stable
Portability | non-portable
Safe Haskell | Trustworthy
Language | Haskell2010

Data.Unique

Contents

- Unique objects

Description

An abstract interface to a unique symbol generator.

Synopsis

- data Unique
- newUnique :: IO Unique
- hashUnique :: Unique -> Int

# Unique objects

data Unique Source #

An abstract unique object. Objects of type `Unique` may be compared for equality and ordering and hashed into `Int`.

    >>> :{
    do x <- newUnique
       print (x == x)
       y <- newUnique
       print (x == y)
    :}
    True
    False

#### Instances

Instances details

Eq Unique Source # |
Instance details Defined in Data.Unique Methods (==) :: Unique -> Unique -> Bool Source # (/=) :: Unique -> Unique -> Bool Source #
Ord Unique Source # |
Instance details Defined in Data.Unique Methods compare :: Unique -> Unique -> Ordering Source # (<) :: Unique -> Unique -> Bool Source # (<=) :: Unique -> Unique -> Bool Source # (>) :: Unique -> Unique -> Bool Source # (>=) :: Unique -> Unique -> Bool Source # max :: Unique -> Unique -> Unique Source # min :: Unique -> Unique -> Unique Source #

newUnique :: IO Unique Source #

Creates a new object of type `Unique`. 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.

hashUnique :: Unique -> Int Source #

Hashes a `Unique` into an `Int`. Two `Unique`s may hash to the same value, although in practice this is unlikely. The `Int` returned makes a good hash key.