Demand

ghc-8.4.4: The GHC API

Safe Haskell | None
Language | Haskell2010

Demand

Synopsis

- data StrDmd
- data UseDmd
  - = UCall Count UseDmd
  - | UProd [ArgUse]
  - | UHead
  - | Used
- data Count
- type Demand = JointDmd ArgStr ArgUse
- type CleanDemand = JointDmd StrDmd UseDmd
- getStrDmd :: JointDmd s u -> s
- getUseDmd :: JointDmd s u -> u
- mkProdDmd :: [Demand] -> CleanDemand
- mkOnceUsedDmd :: CleanDemand -> Demand
- mkManyUsedDmd :: CleanDemand -> Demand
- mkHeadStrict :: CleanDemand -> CleanDemand
- oneifyDmd :: Demand -> Demand
- toCleanDmd :: Demand -> Type -> (DmdShell, CleanDemand)
- absDmd :: Demand
- topDmd :: Demand
- botDmd :: Demand
- seqDmd :: Demand
- lubDmd :: Demand -> Demand -> Demand
- bothDmd :: Demand -> Demand -> Demand
- lazyApply1Dmd :: Demand
- lazyApply2Dmd :: Demand
- strictApply1Dmd :: Demand
- catchArgDmd :: Demand
- isTopDmd :: Demand -> Bool
- isAbsDmd :: Demand -> Bool
- isSeqDmd :: Demand -> Bool
- peelUseCall :: UseDmd -> Maybe (Count, UseDmd)
- cleanUseDmd_maybe :: Demand -> Maybe UseDmd
- strictenDmd :: Demand -> CleanDemand
- bothCleanDmd :: CleanDemand -> CleanDemand -> CleanDemand
- addCaseBndrDmd :: Demand -> [Demand] -> [Demand]
- data DmdType = DmdType DmdEnv [Demand] DmdResult
- dmdTypeDepth :: DmdType -> Arity
- lubDmdType :: DmdType -> DmdType -> DmdType
- bothDmdType :: DmdType -> BothDmdArg -> DmdType
- nopDmdType :: DmdType
- botDmdType :: DmdType
- mkDmdType :: DmdEnv -> [Demand] -> DmdResult -> DmdType
- addDemand :: Demand -> DmdType -> DmdType
- removeDmdTyArgs :: DmdType -> DmdType
- type BothDmdArg = (DmdEnv, Termination ())
- mkBothDmdArg :: DmdEnv -> BothDmdArg
- toBothDmdArg :: DmdType -> BothDmdArg
- type DmdEnv = VarEnv Demand
- emptyDmdEnv :: VarEnv Demand
- peelFV :: DmdType -> Var -> (DmdType, Demand)
- findIdDemand :: DmdType -> Var -> Demand
- type DmdResult = Termination CPRResult
- data CPRResult
- isBotRes :: DmdResult -> Bool
- isTopRes :: DmdResult -> Bool
- topRes :: DmdResult
- botRes :: DmdResult
- exnRes :: DmdResult
- cprProdRes :: [DmdType] -> DmdResult
- vanillaCprProdRes :: Arity -> DmdResult
- cprSumRes :: ConTag -> DmdResult
- appIsBottom :: StrictSig -> Int -> Bool
- isBottomingSig :: StrictSig -> Bool
- pprIfaceStrictSig :: StrictSig -> SDoc
- trimCPRInfo :: Bool -> Bool -> DmdResult -> DmdResult
- returnsCPR_maybe :: DmdResult -> Maybe ConTag
- newtype StrictSig = StrictSig DmdType
- mkStrictSig :: DmdType -> StrictSig
- mkClosedStrictSig :: [Demand] -> DmdResult -> StrictSig
- nopSig :: StrictSig
- botSig :: StrictSig
- exnSig :: StrictSig
- cprProdSig :: Arity -> StrictSig
- isTopSig :: StrictSig -> Bool
- hasDemandEnvSig :: StrictSig -> Bool
- splitStrictSig :: StrictSig -> ([Demand], DmdResult)
- strictSigDmdEnv :: StrictSig -> DmdEnv
- increaseStrictSigArity :: Int -> StrictSig -> StrictSig
- seqDemand :: Demand -> ()
- seqDemandList :: [Demand] -> ()
- seqDmdType :: DmdType -> ()
- seqStrictSig :: StrictSig -> ()
- evalDmd :: Demand
- cleanEvalDmd :: CleanDemand
- cleanEvalProdDmd :: Arity -> CleanDemand
- isStrictDmd :: Demand -> Bool
- splitDmdTy :: DmdType -> (Demand, DmdType)
- splitFVs :: Bool -> DmdEnv -> (DmdEnv, DmdEnv)
- deferAfterIO :: DmdType -> DmdType
- postProcessUnsat :: DmdShell -> DmdType -> DmdType
- postProcessDmdType :: DmdShell -> DmdType -> BothDmdArg
- splitProdDmd_maybe :: Demand -> Maybe [Demand]
- peelCallDmd :: CleanDemand -> (CleanDemand, DmdShell)
- mkCallDmd :: CleanDemand -> CleanDemand
- mkWorkerDemand :: Int -> Demand
- dmdTransformSig :: StrictSig -> CleanDemand -> DmdType
- dmdTransformDataConSig :: Arity -> StrictSig -> CleanDemand -> DmdType
- dmdTransformDictSelSig :: StrictSig -> CleanDemand -> DmdType
- argOneShots :: Demand -> [OneShotInfo]
- argsOneShots :: StrictSig -> Arity -> [[OneShotInfo]]
- saturatedByOneShots :: Int -> Demand -> Bool
- trimToType :: Demand -> TypeShape -> Demand
- data TypeShape
  - = TsFun TypeShape
  - | TsProd [TypeShape]
  - | TsUnk
- useCount :: Use u -> Count
- isUsedOnce :: Demand -> Bool
- reuseEnv :: DmdEnv -> DmdEnv
- killUsageDemand :: DynFlags -> Demand -> Demand
- killUsageSig :: DynFlags -> StrictSig -> StrictSig
- zapUsageDemand :: Demand -> Demand
- zapUsageEnvSig :: StrictSig -> StrictSig
- zapUsedOnceDemand :: Demand -> Demand
- zapUsedOnceSig :: StrictSig -> StrictSig
- strictifyDictDmd :: Type -> Demand -> Demand

# Documentation

data StrDmd #

Vanilla strictness domain

Instances

Eq StrDmd # |
Instance details Defined in Demand Methods (==) :: StrDmd -> StrDmd -> Bool # (/=) :: StrDmd -> StrDmd -> Bool #
Show StrDmd # |
Instance details Defined in Demand Methods showsPrec :: Int -> StrDmd -> ShowS Source # show :: StrDmd -> String Source # showList :: [StrDmd] -> ShowS Source #
Outputable StrDmd # |
Instance details Defined in Demand Methods ppr :: StrDmd -> SDoc # pprPrec :: Rational -> StrDmd -> SDoc #
Binary StrDmd # |
Instance details Defined in Demand Methods put_ :: BinHandle -> StrDmd -> IO () # put :: BinHandle -> StrDmd -> IO (Bin StrDmd) # get :: BinHandle -> IO StrDmd #

data UseDmd #

Domain for genuine usage

Constructors

UCall Count UseDmd | Call demand for absence. Used only for values of function type
UProd [ArgUse] | Product. Used only for values of product type See Note [Don't optimise UProd(Used) to Used] Invariant: Not all components are Abs (in that case, use UHead)
UHead | May be used but its sub-components are definitely *not* used. Roughly U(AAA) e.g. the usage of `x` in `x `seq` e` A polymorphic demand: used for values of all types, including a type variable Since (UCall _ Abs) is ill-typed, UHead doesn't make sense for lambdas
Used | May be used and its sub-components may be used. (top of the lattice)

Instances

Eq UseDmd # |
Instance details Defined in Demand Methods (==) :: UseDmd -> UseDmd -> Bool # (/=) :: UseDmd -> UseDmd -> Bool #
Show UseDmd # |
Instance details Defined in Demand Methods showsPrec :: Int -> UseDmd -> ShowS Source # show :: UseDmd -> String Source # showList :: [UseDmd] -> ShowS Source #
Outputable UseDmd # |
Instance details Defined in Demand Methods ppr :: UseDmd -> SDoc # pprPrec :: Rational -> UseDmd -> SDoc #
Binary UseDmd # |
Instance details Defined in Demand Methods put_ :: BinHandle -> UseDmd -> IO () # put :: BinHandle -> UseDmd -> IO (Bin UseDmd) # get :: BinHandle -> IO UseDmd #

data Count #

Abstract counting of usages

Instances

Eq Count # |
Instance details Defined in Demand Methods (==) :: Count -> Count -> Bool # (/=) :: Count -> Count -> Bool #
Show Count # |
Instance details Defined in Demand Methods showsPrec :: Int -> Count -> ShowS Source # show :: Count -> String Source # showList :: [Count] -> ShowS Source #
Outputable Count # |
Instance details Defined in Demand Methods ppr :: Count -> SDoc # pprPrec :: Rational -> Count -> SDoc #
Binary Count # |
Instance details Defined in Demand Methods put_ :: BinHandle -> Count -> IO () # put :: BinHandle -> Count -> IO (Bin Count) # get :: BinHandle -> IO Count #

type Demand = JointDmd ArgStr ArgUse #

type CleanDemand = JointDmd StrDmd UseDmd #

getStrDmd :: JointDmd s u -> s #

getUseDmd :: JointDmd s u -> u #

mkProdDmd :: [Demand] -> CleanDemand #

mkOnceUsedDmd :: CleanDemand -> Demand #

mkManyUsedDmd :: CleanDemand -> Demand #

mkHeadStrict :: CleanDemand -> CleanDemand #

oneifyDmd :: Demand -> Demand #

toCleanDmd :: Demand -> Type -> (DmdShell, CleanDemand) #

absDmd :: Demand #

topDmd :: Demand #

botDmd :: Demand #

seqDmd :: Demand #

lubDmd :: Demand -> Demand -> Demand #

bothDmd :: Demand -> Demand -> Demand #

lazyApply1Dmd :: Demand #

lazyApply2Dmd :: Demand #

strictApply1Dmd :: Demand #

catchArgDmd :: Demand #

isTopDmd :: Demand -> Bool #

isAbsDmd :: Demand -> Bool #

isSeqDmd :: Demand -> Bool #

peelUseCall :: UseDmd -> Maybe (Count, UseDmd) #

cleanUseDmd_maybe :: Demand -> Maybe UseDmd #

strictenDmd :: Demand -> CleanDemand #

bothCleanDmd :: CleanDemand -> CleanDemand -> CleanDemand #

addCaseBndrDmd :: Demand -> [Demand] -> [Demand] #

data DmdType #

Constructors

DmdType DmdEnv [Demand] DmdResult |

Instances

Eq DmdType # |
Instance details Defined in Demand Methods (==) :: DmdType -> DmdType -> Bool # (/=) :: DmdType -> DmdType -> Bool #
Outputable DmdType # |
Instance details Defined in Demand Methods ppr :: DmdType -> SDoc # pprPrec :: Rational -> DmdType -> SDoc #
Binary DmdType # |
Instance details Defined in Demand Methods put_ :: BinHandle -> DmdType -> IO () # put :: BinHandle -> DmdType -> IO (Bin DmdType) # get :: BinHandle -> IO DmdType #

dmdTypeDepth :: DmdType -> Arity #

lubDmdType :: DmdType -> DmdType -> DmdType #

bothDmdType :: DmdType -> BothDmdArg -> DmdType #

nopDmdType :: DmdType #

botDmdType :: DmdType #

mkDmdType :: DmdEnv -> [Demand] -> DmdResult -> DmdType #

addDemand :: Demand -> DmdType -> DmdType #

removeDmdTyArgs :: DmdType -> DmdType #

type BothDmdArg = (DmdEnv, Termination ()) #

mkBothDmdArg :: DmdEnv -> BothDmdArg #

toBothDmdArg :: DmdType -> BothDmdArg #

type DmdEnv = VarEnv Demand #

emptyDmdEnv :: VarEnv Demand #

peelFV :: DmdType -> Var -> (DmdType, Demand) #

findIdDemand :: DmdType -> Var -> Demand #

type DmdResult = Termination CPRResult #

data CPRResult #

Instances

Eq CPRResult # |
Instance details Defined in Demand Methods (==) :: CPRResult -> CPRResult -> Bool # (/=) :: CPRResult -> CPRResult -> Bool #
Show CPRResult # |
Instance details Defined in Demand Methods showsPrec :: Int -> CPRResult -> ShowS Source # show :: CPRResult -> String Source # showList :: [CPRResult] -> ShowS Source #
Outputable CPRResult # |
Instance details Defined in Demand Methods ppr :: CPRResult -> SDoc # pprPrec :: Rational -> CPRResult -> SDoc #
Binary CPRResult # |
Instance details Defined in Demand Methods put_ :: BinHandle -> CPRResult -> IO () # put :: BinHandle -> CPRResult -> IO (Bin CPRResult) # get :: BinHandle -> IO CPRResult #
Binary DmdResult # |
Instance details Defined in Demand Methods put_ :: BinHandle -> DmdResult -> IO () # put :: BinHandle -> DmdResult -> IO (Bin DmdResult) # get :: BinHandle -> IO DmdResult #

isBotRes :: DmdResult -> Bool #

isTopRes :: DmdResult -> Bool #

topRes :: DmdResult #

botRes :: DmdResult #

exnRes :: DmdResult #

cprProdRes :: [DmdType] -> DmdResult #

vanillaCprProdRes :: Arity -> DmdResult #

cprSumRes :: ConTag -> DmdResult #

appIsBottom :: StrictSig -> Int -> Bool #

isBottomingSig :: StrictSig -> Bool #

pprIfaceStrictSig :: StrictSig -> SDoc #

trimCPRInfo :: Bool -> Bool -> DmdResult -> DmdResult #

returnsCPR_maybe :: DmdResult -> Maybe ConTag #

newtype StrictSig #

Constructors

StrictSig DmdType |

Instances

Eq StrictSig # |
Instance details Defined in Demand Methods (==) :: StrictSig -> StrictSig -> Bool # (/=) :: StrictSig -> StrictSig -> Bool #
Outputable StrictSig # |
Instance details Defined in Demand Methods ppr :: StrictSig -> SDoc # pprPrec :: Rational -> StrictSig -> SDoc #
Binary StrictSig # |
Instance details Defined in Demand Methods put_ :: BinHandle -> StrictSig -> IO () # put :: BinHandle -> StrictSig -> IO (Bin StrictSig) # get :: BinHandle -> IO StrictSig #

mkStrictSig :: DmdType -> StrictSig #

mkClosedStrictSig :: [Demand] -> DmdResult -> StrictSig #

nopSig :: StrictSig #

botSig :: StrictSig #

exnSig :: StrictSig #

cprProdSig :: Arity -> StrictSig #

isTopSig :: StrictSig -> Bool #

hasDemandEnvSig :: StrictSig -> Bool #

splitStrictSig :: StrictSig -> ([Demand], DmdResult) #

strictSigDmdEnv :: StrictSig -> DmdEnv #

increaseStrictSigArity :: Int -> StrictSig -> StrictSig #

seqDemand :: Demand -> () #

seqDemandList :: [Demand] -> () #

seqDmdType :: DmdType -> () #

seqStrictSig :: StrictSig -> () #

evalDmd :: Demand #

cleanEvalDmd :: CleanDemand #

cleanEvalProdDmd :: Arity -> CleanDemand #

isStrictDmd :: Demand -> Bool #

splitDmdTy :: DmdType -> (Demand, DmdType) #

splitFVs :: Bool -> DmdEnv -> (DmdEnv, DmdEnv) #

deferAfterIO :: DmdType -> DmdType #

postProcessUnsat :: DmdShell -> DmdType -> DmdType #

postProcessDmdType :: DmdShell -> DmdType -> BothDmdArg #

splitProdDmd_maybe :: Demand -> Maybe [Demand] #

peelCallDmd :: CleanDemand -> (CleanDemand, DmdShell) #

mkCallDmd :: CleanDemand -> CleanDemand #

mkWorkerDemand :: Int -> Demand #

dmdTransformSig :: StrictSig -> CleanDemand -> DmdType #

dmdTransformDataConSig :: Arity -> StrictSig -> CleanDemand -> DmdType #

dmdTransformDictSelSig :: StrictSig -> CleanDemand -> DmdType #

argOneShots :: Demand -> [OneShotInfo] #

argsOneShots :: StrictSig -> Arity -> [[OneShotInfo]] #

saturatedByOneShots :: Int -> Demand -> Bool #

trimToType :: Demand -> TypeShape -> Demand #

data TypeShape #

Constructors

TsFun TypeShape |
TsProd [TypeShape] |
TsUnk |

Instances

Outputable TypeShape # |
Instance details Defined in Demand Methods ppr :: TypeShape -> SDoc # pprPrec :: Rational -> TypeShape -> SDoc #

useCount :: Use u -> Count #

isUsedOnce :: Demand -> Bool #

reuseEnv :: DmdEnv -> DmdEnv #

killUsageDemand :: DynFlags -> Demand -> Demand #

killUsageSig :: DynFlags -> StrictSig -> StrictSig #

zapUsageDemand :: Demand -> Demand #

zapUsageEnvSig :: StrictSig -> StrictSig #

zapUsedOnceDemand :: Demand -> Demand #

Remove all 1* information (but not C1 information) from the demand

zapUsedOnceSig :: StrictSig -> StrictSig #

Remove all 1* information (but not C1 information) from the strictness signature

strictifyDictDmd :: Type -> Demand -> Demand #