ghc-7.0.3: The GHC API

UniqSupply

Contents

- Main data type
  - Operations on supplies
- Unique supply monad and its abstraction
  - Operations on the monad
  - Deprecated operations on `UniqSM`

Synopsis

- data UniqSupply
- uniqFromSupply :: UniqSupply -> Unique
- uniqsFromSupply :: UniqSupply -> [Unique]
- mkSplitUniqSupply :: Char -> IO UniqSupply
- splitUniqSupply :: UniqSupply -> (UniqSupply, UniqSupply)
- listSplitUniqSupply :: UniqSupply -> [UniqSupply]
- data UniqSM result
- class Monad m => MonadUnique m where
  - getUniqueSupplyM :: m UniqSupply
  - getUniqueM :: m Unique
  - getUniquesM :: m [Unique]
- initUs :: UniqSupply -> UniqSM a -> (a, UniqSupply)
- initUs_ :: UniqSupply -> UniqSM a -> a
- lazyThenUs :: UniqSM a -> (a -> UniqSM b) -> UniqSM b
- lazyMapUs :: (a -> UniqSM b) -> [a] -> UniqSM [b]
- getUniqueUs :: UniqSM Unique
- getUs :: UniqSM UniqSupply
- returnUs :: a -> UniqSM a
- thenUs :: UniqSM a -> (a -> UniqSM b) -> UniqSM b
- mapUs :: (a -> UniqSM b) -> [a] -> UniqSM [b]

# Main data type

data UniqSupply Source

A value of type `UniqSupply` is unique, and it can supply one distinct `Unique`. Also, from the supply, one can also manufacture an arbitrary number of further `UniqueSupply` values, which will be distinct from the first and from all others.

## Operations on supplies

uniqFromSupply :: UniqSupply -> Unique Source

Obtain the `Unique` from this particular `UniqSupply`

uniqsFromSupply :: UniqSupply -> [Unique]Source

Obtain an infinite list of `Unique` that can be generated by constant splitting of the supply

mkSplitUniqSupply :: Char -> IO UniqSupply Source

Create a unique supply out of thin air. The character given must be distinct from those of all calls to this function in the compiler for the values generated to be truly unique.

splitUniqSupply :: UniqSupply -> (UniqSupply, UniqSupply)Source

Build two `UniqSupply` from a single one, each of which can supply its own `Unique`.

listSplitUniqSupply :: UniqSupply -> [UniqSupply]Source

Create an infinite list of `UniqSupply` from a single one

# Unique supply monad and its abstraction

data UniqSM result Source

A monad which just gives the ability to obtain `Unique`s

Instances

Monad UniqSM |
Functor UniqSM |
MonadFix UniqSM |
Applicative UniqSM |
MonadUnique UniqSM |

class Monad m => MonadUnique m where Source

A monad for generating unique identifiers

Methods

getUniqueSupplyM :: m UniqSupply Source

Get a new UniqueSupply

getUniqueM :: m Unique Source

Get a new unique identifier

getUniquesM :: m [Unique]Source

Get an infinite list of new unique identifiers

Instances

MonadUnique UniqSM |
MonadUnique FuelMonad |
MonadUnique CoreM |
MonadUnique SimplM |
MonadUnique (IOEnv (Env gbl lcl)) |
MonadUnique (DFM' FuelMonad f) |

## Operations on the monad

initUs :: UniqSupply -> UniqSM a -> (a, UniqSupply)Source

Run the `UniqSM` action, returning the final `UniqSupply`

initUs_ :: UniqSupply -> UniqSM a -> aSource

Run the `UniqSM` action, discarding the final `UniqSupply`

lazyThenUs :: UniqSM a -> (a -> UniqSM b) -> UniqSM bSource

lazyMapUs :: (a -> UniqSM b) -> [a] -> UniqSM [b]Source

## Deprecated operations on `UniqSM`

getUniqueUs :: UniqSM Unique Source

getUs :: UniqSM UniqSupply Source

returnUs :: a -> UniqSM aSource

thenUs :: UniqSM a -> (a -> UniqSM b) -> UniqSM bSource

mapUs :: (a -> UniqSM b) -> [a] -> UniqSM [b]Source