ghc-lib-parser-9.12.2.20250421: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Types.Unique.DSM

Contents

- Threading a deterministic supply
  - UniqDSM and DUniqSupply operations
  - Tag operations
- A transfomer threading a deterministic supply
  - UniqDSMT operations
  - Tags
- Monad class for deterministic supply threading

Synopsis

- data DUniqSupply
- data UniqDSM result where
  - pattern UDSM :: (DUniqSupply -> DUniqResult a) -> UniqDSM a
- type DUniqResult result = (# result, DUniqSupply #)
- pattern DUniqResult :: a -> DUniqSupply -> (# a, DUniqSupply #)
- getUniqueDSM :: UniqDSM Unique
- runUniqueDSM :: DUniqSupply -> UniqDSM a -> (a, DUniqSupply)
- takeUniqueFromDSupply :: DUniqSupply -> (Unique, DUniqSupply)
- initDUniqSupply :: Char -> Word64 -> DUniqSupply
- newTagDUniqSupply :: Char -> DUniqSupply -> DUniqSupply
- getTagDUniqSupply :: DUniqSupply -> Char
- data UniqDSMT (m :: Type -> Type) result where
  - pattern UDSMT :: (DUniqSupply -> m (result, DUniqSupply)) -> UniqDSMT m result
- runUDSMT :: DUniqSupply -> UniqDSMT m a -> m (a, DUniqSupply)
- withDUS :: (DUniqSupply -> IO (a, DUniqSupply)) -> UniqDSMT IO a
- hoistUDSMT :: (forall x. m x -> n x) -> UniqDSMT m a -> UniqDSMT n a
- liftUDSMT :: Functor m => m a -> UniqDSMT m a
- setTagUDSMT :: forall (m :: Type -> Type) a. Monad m => Char -> UniqDSMT m a -> UniqDSMT m a
- class Monad m => MonadGetUnique (m :: Type -> Type) where
  - getUniqueM :: m Unique
- class Monad m => MonadUniqDSM (m :: Type -> Type) where
  - liftUniqDSM :: UniqDSM a -> m a

# Threading a deterministic supply

data DUniqSupply Source #

data UniqDSM result where Source #

A monad which just gives the ability to obtain `Unique`s deterministically. There's no splitting.

Bundled Patterns

pattern UDSM :: (DUniqSupply -> DUniqResult a) -> UniqDSM a |

#### Instances

Instances details

Applicative UniqDSM Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods pure :: a -> UniqDSM a Source # (<*>) :: UniqDSM (a -> b) -> UniqDSM a -> UniqDSM b Source # liftA2 :: (a -> b -> c) -> UniqDSM a -> UniqDSM b -> UniqDSM c Source # (*>) :: UniqDSM a -> UniqDSM b -> UniqDSM b Source # (<*) :: UniqDSM a -> UniqDSM b -> UniqDSM a Source #
Functor UniqDSM Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods fmap :: (a -> b) -> UniqDSM a -> UniqDSM b Source # (<$) :: a -> UniqDSM b -> UniqDSM a Source #
Monad UniqDSM Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods (>>=) :: UniqDSM a -> (a -> UniqDSM b) -> UniqDSM b Source # (>>) :: UniqDSM a -> UniqDSM b -> UniqDSM b Source # return :: a -> UniqDSM a Source #
MonadFix UniqDSM Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods mfix :: (a -> UniqDSM a) -> UniqDSM a Source #
MonadGetUnique UniqDSM Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods getUniqueM :: UniqDSM Unique Source #
MonadUniqDSM UniqDSM Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods liftUniqDSM :: UniqDSM a -> UniqDSM a Source #

type DUniqResult result = (# result, DUniqSupply #) Source #

pattern DUniqResult :: a -> DUniqSupply -> (# a, DUniqSupply #) Source #

## UniqDSM and DUniqSupply operations

getUniqueDSM :: UniqDSM Unique Source #

runUniqueDSM :: DUniqSupply -> UniqDSM a -> (a, DUniqSupply) Source #

takeUniqueFromDSupply :: DUniqSupply -> (Unique, DUniqSupply) Source #

initDUniqSupply :: Char -> Word64 -> DUniqSupply Source #

Initialize a deterministic unique supply with the given Tag and initial unique.

## Tag operations

newTagDUniqSupply :: Char -> DUniqSupply -> DUniqSupply Source #

Set the tag of uniques generated from this deterministic unique supply

getTagDUniqSupply :: DUniqSupply -> Char Source #

Get the tag uniques generated from this deterministic unique supply would have

# A transfomer threading a deterministic supply

data UniqDSMT (m :: Type -> Type) result where Source #

Transformer version of `UniqDSM` to use when threading a deterministic uniq supply over a Monad. Specifically, it is used in the `Stream` of Cmm decls.

Bundled Patterns

pattern UDSMT :: (DUniqSupply -> m (result, DUniqSupply)) -> UniqDSMT m result |

#### Instances

Instances details

MonadIO m => MonadIO (UniqDSMT m) Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods liftIO :: IO a -> UniqDSMT m a Source #
Monad m => Applicative (UniqDSMT m) Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods pure :: a -> UniqDSMT m a Source # (<*>) :: UniqDSMT m (a -> b) -> UniqDSMT m a -> UniqDSMT m b Source # liftA2 :: (a -> b -> c) -> UniqDSMT m a -> UniqDSMT m b -> UniqDSMT m c Source # (*>) :: UniqDSMT m a -> UniqDSMT m b -> UniqDSMT m b Source # (<*) :: UniqDSMT m a -> UniqDSMT m b -> UniqDSMT m a Source #
Functor m => Functor (UniqDSMT m) Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods fmap :: (a -> b) -> UniqDSMT m a -> UniqDSMT m b Source # (<$) :: a -> UniqDSMT m b -> UniqDSMT m a Source #
Monad m => Monad (UniqDSMT m) Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods (>>=) :: UniqDSMT m a -> (a -> UniqDSMT m b) -> UniqDSMT m b Source # (>>) :: UniqDSMT m a -> UniqDSMT m b -> UniqDSMT m b Source # return :: a -> UniqDSMT m a Source #
Monad m => MonadGetUnique (UniqDSMT m) Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods getUniqueM :: UniqDSMT m Unique Source #
Monad m => MonadUniqDSM (UniqDSMT m) Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods liftUniqDSM :: UniqDSM a -> UniqDSMT m a Source #

## UniqDSMT operations

runUDSMT :: DUniqSupply -> UniqDSMT m a -> m (a, DUniqSupply) Source #

Like `runUniqueDSM` but for `UniqDSMT`

withDUS :: (DUniqSupply -> IO (a, DUniqSupply)) -> UniqDSMT IO a Source #

Lift an IO action that depends on, and threads through, a unique supply into UniqDSMT IO.

hoistUDSMT :: (forall x. m x -> n x) -> UniqDSMT m a -> UniqDSMT n a Source #

Change the monad underyling an applied `UniqDSMT`, i.e. transform a `UniqDSMT m` into a `UniqDSMT n` given `m ~> n`.

liftUDSMT :: Functor m => m a -> UniqDSMT m a Source #

Lift a monadic action `m a` into an `UniqDSMT m a`

## Tags

setTagUDSMT Source #

Arguments

:: forall (m :: Type -> Type) a. Monad m |
=> Char | Tag
-> UniqDSMT m a |
-> UniqDSMT m a |

Set the tag of the running `UniqDSMT` supply to the given tag and run an action with it. All uniques produced in the given action will use this tag, until the tag is changed again.

# Monad class for deterministic supply threading

class Monad m => MonadGetUnique (m :: Type -> Type) where Source #

Get a unique from a monad that can access a unique supply.

Crucially, because `MonadGetUnique` doesn't allow you to get the `UniqSupply` (unlike `MonadUnique`), an instance such as `UniqDSM` can use a deterministic unique supply to return deterministic uniques without allowing for the `UniqSupply` to be shared.

Methods

getUniqueM :: m Unique Source #

#### Instances

Instances details

MonadGetUnique UniqDSM Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods getUniqueM :: UniqDSM Unique Source #
MonadGetUnique UniqSM Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods getUniqueM :: UniqSM Unique Source #
Monad m => MonadGetUnique (UniqDSMT m) Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods getUniqueM :: UniqDSMT m Unique Source #

class Monad m => MonadUniqDSM (m :: Type -> Type) where Source #

Methods

liftUniqDSM :: UniqDSM a -> m a Source #

Lift a pure `UniqDSM` action into a `MonadUniqDSM` such as `UniqDSMT`

#### Instances

Instances details

MonadUniqDSM UniqDSM Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods liftUniqDSM :: UniqDSM a -> UniqDSM a Source #
Monad m => MonadUniqDSM (UniqDSMT m) Source # |
Instance details Defined in GHC.Types.Unique.DSM Methods liftUniqDSM :: UniqDSM a -> UniqDSMT m a Source #