prim-uniq-0.2: Opaque unique identifiers in primitive state monads

Safe Haskell | Trustworthy
Language | Haskell98

Data.Unique.Prim

Synopsis

- data Uniq s
- getUniq :: PrimMonad m => m (Uniq (PrimState m))
- data RealWorld

# Documentation

data Uniq s Source #

A `Uniq` is a value that can only be constructed under controlled conditions (in IO or ST, basically), and once constructed can only be compared to `Uniq` values created under the same conditions (in the same monad). Upon comparison, a `Uniq` is ONLY ever equal to itself. Beyond that, no promises regarding ordering are made except that once constructed the order is deterministic and a proper ordering relation (eg, > is transitive and irreflexive, etc.)

#### Instances

Instances details

Show (Uniq RealWorld) Source #

There is only one `RealWorld`, so this instance is sound (unlike the general `unsafeShowsPrecUniq`). Note that there is no particular relationship between `Uniq` values (or the strings `show` turns them into) created in different executions of a program. The value they render to should be considered completely arbitrary, and the Show instance only even exists for convenience when testing code that uses `Uniq`s.

Instance details Defined in Unsafe.Unique.Prim Methods showsPrec :: Int -> Uniq RealWorld -> ShowS Source # show :: Uniq RealWorld -> String Source # showList :: [Uniq RealWorld] -> ShowS Source #
Eq (Uniq s) Source # |
Instance details Defined in Unsafe.Unique.Prim Methods (==) :: Uniq s -> Uniq s -> Bool Source # (/=) :: Uniq s -> Uniq s -> Bool Source #
Ord (Uniq s) Source # |
Instance details Defined in Unsafe.Unique.Prim Methods compare :: Uniq s -> Uniq s -> Ordering Source # (<) :: Uniq s -> Uniq s -> Bool Source # (<=) :: Uniq s -> Uniq s -> Bool Source # (>) :: Uniq s -> Uniq s -> Bool Source # (>=) :: Uniq s -> Uniq s -> Bool Source # max :: Uniq s -> Uniq s -> Uniq s Source # min :: Uniq s -> Uniq s -> Uniq s Source #

getUniq :: PrimMonad m => m (Uniq (PrimState m)) Source #

Construct a new `Uniq` that is equal to itself, unequal to every other `Uniq` constructed in the same monad, and incomparable to every `Uniq` constructed in any other monad.

data RealWorld Source #

`RealWorld` is deeply magical. It is primitive, but it is not unlifted (hence `ptrArg`). We never manipulate values of type `RealWorld`; it's only used in the type system, to parameterise `State#`.

#### Instances

Instances details

GShow (Tag RealWorld) |
Instance details Defined in Unsafe.Unique.Tag Methods gshowsPrec :: Int -> Tag RealWorld a -> ShowS

Show (Uniq RealWorld) Source #

There is only one `RealWorld`, so this instance is sound (unlike the general `unsafeShowsPrecUniq`). Note that there is no particular relationship between `Uniq` values (or the strings `show` turns them into) created in different executions of a program. The value they render to should be considered completely arbitrary, and the Show instance only even exists for convenience when testing code that uses `Uniq`s.

Instance details Defined in Unsafe.Unique.Prim Methods showsPrec :: Int -> Uniq RealWorld -> ShowS Source # show :: Uniq RealWorld -> String Source # showList :: [Uniq RealWorld] -> ShowS Source #
Show (Tag RealWorld a) Source # |
Instance details Defined in Unsafe.Unique.Tag Methods showsPrec :: Int -> Tag RealWorld a -> ShowS Source # show :: Tag RealWorld a -> String Source # showList :: [Tag RealWorld a] -> ShowS Source #