ghc-9.0.0.20201227: The GHC API
Safe HaskellNone
LanguageHaskell2010

GHC.Types.Unique.Supply

Synopsis

Main data type

data UniqSupply Source #

Unique Supply

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

takeUniqFromSupply :: UniqSupply -> (Unique, UniqSupply) Source #

Obtain the Unique from this particular UniqSupply, and a new 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 Uniques

Instances

Instances details
Monad UniqSM # 
Instance details

Defined in GHC.Types.Unique.Supply

Methods

(>>=) :: UniqSM a -> (a -> UniqSM b) -> UniqSM b Source #

(>>) :: UniqSM a -> UniqSM b -> UniqSM b Source #

return :: a -> UniqSM a Source #

Functor UniqSM # 
Instance details

Defined in GHC.Types.Unique.Supply

Methods

fmap :: (a -> b) -> UniqSM a -> UniqSM b Source #

(<$) :: a -> UniqSM b -> UniqSM a Source #

MonadFix UniqSM # 
Instance details

Defined in GHC.Types.Unique.Supply

Methods

mfix :: (a -> UniqSM a) -> UniqSM a Source #

MonadFail UniqSM # 
Instance details

Defined in GHC.Types.Unique.Supply

Methods

fail :: String -> UniqSM a Source #

Applicative UniqSM # 
Instance details

Defined in GHC.Types.Unique.Supply

Methods

pure :: a -> UniqSM a Source #

(<*>) :: UniqSM (a -> b) -> UniqSM a -> UniqSM b Source #

liftA2 :: (a -> b -> c) -> UniqSM a -> UniqSM b -> UniqSM c Source #

(*>) :: UniqSM a -> UniqSM b -> UniqSM b Source #

(<*) :: UniqSM a -> UniqSM b -> UniqSM a Source #

MonadUnique UniqSM # 
Instance details

Defined in GHC.Types.Unique.Supply

class Monad m => MonadUnique m where Source #

A monad for generating unique identifiers

Minimal complete definition

getUniqueSupplyM

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

Instances details
MonadUnique UniqSM # 
Instance details

Defined in GHC.Types.Unique.Supply

MonadUnique CoreM # 
Instance details

Defined in GHC.Core.Opt.Monad

MonadUnique LiftM # 
Instance details

Defined in GHC.Stg.Lift.Monad

MonadUnique SimplM # 
Instance details

Defined in GHC.Core.Opt.Simplify.Monad

MonadUnique TcS # 
Instance details

Defined in GHC.Tc.Solver.Monad

MonadUnique LlvmM # 
Instance details

Defined in GHC.CmmToLlvm.Base

MonadUnique NatM # 
Instance details

Defined in GHC.CmmToAsm.Monad

MonadUnique FCode # 
Instance details

Defined in GHC.StgToCmm.Monad

MonadUnique CmmParse # 
Instance details

Defined in GHC.StgToCmm.ExtCode

MonadUnique (IOEnv (Env gbl lcl)) # 
Instance details

Defined in GHC.Tc.Utils.Monad

Operations on the monad

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

Run the UniqSM action, returning the final UniqSupply

initUs_ :: UniqSupply -> UniqSM a -> a Source #

Run the UniqSM action, discarding the final UniqSupply

Set supply strategy