ghc-9.12: The GHC API
Safe HaskellNone
LanguageGHC2021

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 "tag" (Char) supplied is mostly cosmetic, making it easier to figure out where a Unique was born. See Note [Uniques and tags].

The payload part of the Uniques allocated from this UniqSupply are guaranteed distinct wrt all other supplies, regardless of their "tag". This is achieved by allocating the payload part from a single source of Uniques, namely genSym, shared across all UniqSupply's.

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
MonadGetUnique UniqSM Source # 
Instance details

Defined in GHC.Types.Unique.DSM

MonadUnique UniqSM Source # 
Instance details

Defined in GHC.Types.Unique.Supply

Applicative UniqSM Source # 
Instance details

Defined in GHC.Types.Unique.Supply

Methods

pure :: a -> UniqSM a #

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

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

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

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

Functor UniqSM Source # 
Instance details

Defined in GHC.Types.Unique.Supply

Methods

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

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

Monad UniqSM Source # 
Instance details

Defined in GHC.Types.Unique.Supply

Methods

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

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

return :: a -> UniqSM a #

MonadFail UniqSM Source # 
Instance details

Defined in GHC.Types.Unique.Supply

Methods

fail :: String -> UniqSM a #

MonadFix UniqSM Source # 
Instance details

Defined in GHC.Types.Unique.Supply

Methods

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

class Monad m => MonadUnique (m :: Type -> Type) 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 CoreM Source # 
Instance details

Defined in GHC.Core.Opt.Monad

MonadUnique SimplM Source # 
Instance details

Defined in GHC.Core.Opt.Simplify.Monad

MonadUnique LiftM Source # 
Instance details

Defined in GHC.Stg.Lift.Monad

MonadUnique CmmParse Source # 
Instance details

Defined in GHC.StgToCmm.ExtCode

MonadUnique FCode Source # 
Instance details

Defined in GHC.StgToCmm.Monad

MonadUnique TcS Source # 
Instance details

Defined in GHC.Tc.Solver.Monad

MonadUnique UniqSM Source # 
Instance details

Defined in GHC.Types.Unique.Supply

MonadUnique (IOEnv (Env gbl lcl)) Source # 
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