Demand

ghc-8.8.1.20191211: 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 DmdShell = JointDmd (Str ()) (Use ())
- 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 :: JointDmd s (Use u) -> JointDmd s (Use u)
- toCleanDmd :: Demand -> (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 :: JointDmd (Str s) (Use u) -> 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
- etaExpandStrictSig :: Arity -> StrictSig -> StrictSig
- seqDemand :: Demand -> ()
- seqDemandList :: [Demand] -> ()
- seqDmdType :: DmdType -> ()
- seqStrictSig :: StrictSig -> ()
- evalDmd :: Demand
- cleanEvalDmd :: CleanDemand
- cleanEvalProdDmd :: Arity -> CleanDemand
- isStrictDmd :: JointDmd (Str s) (Use u) -> 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)
- peelManyCalls :: Int -> 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 :: JointDmd (Str s) (Use u) -> 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
- strictifyDmd :: Demand -> Demand

# Documentation

data StrDmd Source #

Vanilla strictness domain

#### Instances

Instances details

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 Source # pprPrec :: Rational -> StrDmd -> SDoc Source #
Binary StrDmd # |
Instance details Defined in Demand Methods put_ :: BinHandle -> StrDmd -> IO () Source # put :: BinHandle -> StrDmd -> IO (Bin StrDmd) Source # get :: BinHandle -> IO StrDmd Source #

data UseDmd Source #

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. For product types, UHead is equivalent to U(AAA); see mkUProd. UHead is needed only to express the demand of `seq` and 'case' which are polymorphic; i.e. the scrutinised value is of type `a` rather than a product type. That's why we can't use UProd [A,A,A] 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

Instances details

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 Source # pprPrec :: Rational -> UseDmd -> SDoc Source #
Binary UseDmd # |
Instance details Defined in Demand Methods put_ :: BinHandle -> UseDmd -> IO () Source # put :: BinHandle -> UseDmd -> IO (Bin UseDmd) Source # get :: BinHandle -> IO UseDmd Source #

data Count Source #

Abstract counting of usages

#### Instances

Instances details

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 Source # pprPrec :: Rational -> Count -> SDoc Source #
Binary Count # |
Instance details Defined in Demand Methods put_ :: BinHandle -> Count -> IO () Source # put :: BinHandle -> Count -> IO (Bin Count) Source # get :: BinHandle -> IO Count Source #

type Demand = JointDmd ArgStr ArgUse Source #

type DmdShell = JointDmd (Str ()) (Use ()) Source #

type CleanDemand = JointDmd StrDmd UseDmd Source #

getStrDmd :: JointDmd s u -> s Source #

getUseDmd :: JointDmd s u -> u Source #

mkProdDmd :: [Demand] -> CleanDemand Source #

mkOnceUsedDmd :: CleanDemand -> Demand Source #

mkManyUsedDmd :: CleanDemand -> Demand Source #

mkHeadStrict :: CleanDemand -> CleanDemand Source #

oneifyDmd :: JointDmd s (Use u) -> JointDmd s (Use u) Source #

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

absDmd :: Demand Source #

topDmd :: Demand Source #

botDmd :: Demand Source #

seqDmd :: Demand Source #

lubDmd :: Demand -> Demand -> Demand Source #

bothDmd :: Demand -> Demand -> Demand Source #

lazyApply1Dmd :: Demand Source #

lazyApply2Dmd :: Demand Source #

strictApply1Dmd :: Demand Source #

catchArgDmd :: Demand Source #

isTopDmd :: Demand -> Bool Source #

isAbsDmd :: JointDmd (Str s) (Use u) -> Bool Source #

isSeqDmd :: Demand -> Bool Source #

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

cleanUseDmd_maybe :: Demand -> Maybe UseDmd Source #

strictenDmd :: Demand -> CleanDemand Source #

bothCleanDmd :: CleanDemand -> CleanDemand -> CleanDemand Source #

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

data DmdType Source #

Constructors

DmdType DmdEnv [Demand] DmdResult |

#### Instances

Instances details

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 Source # pprPrec :: Rational -> DmdType -> SDoc Source #
Binary DmdType # |
Instance details Defined in Demand Methods put_ :: BinHandle -> DmdType -> IO () Source # put :: BinHandle -> DmdType -> IO (Bin DmdType) Source # get :: BinHandle -> IO DmdType Source #

dmdTypeDepth :: DmdType -> Arity Source #

lubDmdType :: DmdType -> DmdType -> DmdType Source #

bothDmdType :: DmdType -> BothDmdArg -> DmdType Source #

nopDmdType :: DmdType Source #

botDmdType :: DmdType Source #

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

addDemand :: Demand -> DmdType -> DmdType Source #

removeDmdTyArgs :: DmdType -> DmdType Source #

type BothDmdArg = (DmdEnv, Termination ()) Source #

mkBothDmdArg :: DmdEnv -> BothDmdArg Source #

toBothDmdArg :: DmdType -> BothDmdArg Source #

type DmdEnv = VarEnv Demand Source #

emptyDmdEnv :: VarEnv Demand Source #

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

findIdDemand :: DmdType -> Var -> Demand Source #

type DmdResult = Termination CPRResult Source #

data CPRResult Source #

#### Instances

Instances details

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 Source # pprPrec :: Rational -> CPRResult -> SDoc Source #
Binary CPRResult # |
Instance details Defined in Demand Methods put_ :: BinHandle -> CPRResult -> IO () Source # put :: BinHandle -> CPRResult -> IO (Bin CPRResult) Source # get :: BinHandle -> IO CPRResult Source #
Binary DmdResult # |
Instance details Defined in Demand Methods put_ :: BinHandle -> DmdResult -> IO () Source # put :: BinHandle -> DmdResult -> IO (Bin DmdResult) Source # get :: BinHandle -> IO DmdResult Source #

isBotRes :: DmdResult -> Bool Source #

isTopRes :: DmdResult -> Bool Source #

topRes :: DmdResult Source #

botRes :: DmdResult Source #

exnRes :: DmdResult Source #

cprProdRes :: [DmdType] -> DmdResult Source #

vanillaCprProdRes :: Arity -> DmdResult Source #

cprSumRes :: ConTag -> DmdResult Source #

appIsBottom :: StrictSig -> Int -> Bool Source #

isBottomingSig :: StrictSig -> Bool Source #

pprIfaceStrictSig :: StrictSig -> SDoc Source #

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

returnsCPR_maybe :: DmdResult -> Maybe ConTag Source #

newtype StrictSig Source #

Constructors

StrictSig DmdType |

#### Instances

Instances details

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 Source # pprPrec :: Rational -> StrictSig -> SDoc Source #
Binary StrictSig # |
Instance details Defined in Demand Methods put_ :: BinHandle -> StrictSig -> IO () Source # put :: BinHandle -> StrictSig -> IO (Bin StrictSig) Source # get :: BinHandle -> IO StrictSig Source #

mkStrictSig :: DmdType -> StrictSig Source #

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

nopSig :: StrictSig Source #

botSig :: StrictSig Source #

exnSig :: StrictSig Source #

cprProdSig :: Arity -> StrictSig Source #

isTopSig :: StrictSig -> Bool Source #

hasDemandEnvSig :: StrictSig -> Bool Source #

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

strictSigDmdEnv :: StrictSig -> DmdEnv Source #

increaseStrictSigArity :: Int -> StrictSig -> StrictSig Source #

etaExpandStrictSig :: Arity -> StrictSig -> StrictSig Source #

seqDemand :: Demand -> () Source #

seqDemandList :: [Demand] -> () Source #

seqDmdType :: DmdType -> () Source #

seqStrictSig :: StrictSig -> () Source #

evalDmd :: Demand Source #

cleanEvalDmd :: CleanDemand Source #

cleanEvalProdDmd :: Arity -> CleanDemand Source #

isStrictDmd :: JointDmd (Str s) (Use u) -> Bool Source #

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

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

deferAfterIO :: DmdType -> DmdType Source #

postProcessUnsat :: DmdShell -> DmdType -> DmdType Source #

postProcessDmdType :: DmdShell -> DmdType -> BothDmdArg Source #

splitProdDmd_maybe :: Demand -> Maybe [Demand] Source #

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

peelManyCalls :: Int -> CleanDemand -> DmdShell Source #

mkCallDmd :: CleanDemand -> CleanDemand Source #

mkWorkerDemand :: Int -> Demand Source #

dmdTransformSig :: StrictSig -> CleanDemand -> DmdType Source #

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

dmdTransformDictSelSig :: StrictSig -> CleanDemand -> DmdType Source #

argOneShots :: Demand -> [OneShotInfo] Source #

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

saturatedByOneShots :: Int -> Demand -> Bool Source #

trimToType :: Demand -> TypeShape -> Demand Source #

data TypeShape Source #

Constructors

TsFun TypeShape |
TsProd [TypeShape] |
TsUnk |

#### Instances

Instances details

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

useCount :: Use u -> Count Source #

isUsedOnce :: JointDmd (Str s) (Use u) -> Bool Source #

reuseEnv :: DmdEnv -> DmdEnv Source #

killUsageDemand :: DynFlags -> Demand -> Demand Source #

killUsageSig :: DynFlags -> StrictSig -> StrictSig Source #

zapUsageDemand :: Demand -> Demand Source #

zapUsageEnvSig :: StrictSig -> StrictSig Source #

zapUsedOnceDemand :: Demand -> Demand Source #

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

zapUsedOnceSig :: StrictSig -> StrictSig Source #

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

strictifyDictDmd :: Type -> Demand -> Demand Source #

strictifyDmd :: Demand -> Demand Source #