DsUtils

ghc-8.8.0.20190721: The GHC API

Safe Haskell | None
Language | Haskell2010

DsUtils

Description

Utility functions for constructing Core syntax, principally for desugaring

Synopsis

- data EquationInfo = EqnInfo {
  - eqn_pats :: [Pat GhcTc]
  - eqn_orig :: Origin
  - eqn_rhs :: MatchResult
  }
- firstPat :: EquationInfo -> Pat GhcTc
- shiftEqns :: [EquationInfo] -> [EquationInfo]
- data MatchResult = MatchResult CanItFail (CoreExpr -> DsM CoreExpr)
- data CanItFail
  - = CanFail
  - | CantFail
- data CaseAlt a = MkCaseAlt {
  - alt_pat :: a
  - alt_bndrs :: [Var]
  - alt_wrapper :: HsWrapper
  - alt_result :: MatchResult
  }
- cantFailMatchResult :: CoreExpr -> MatchResult
- alwaysFailMatchResult :: MatchResult
- extractMatchResult :: MatchResult -> CoreExpr -> DsM CoreExpr
- combineMatchResults :: MatchResult -> MatchResult -> MatchResult
- adjustMatchResult :: DsWrapper -> MatchResult -> MatchResult
- adjustMatchResultDs :: (CoreExpr -> DsM CoreExpr) -> MatchResult -> MatchResult
- mkCoLetMatchResult :: CoreBind -> MatchResult -> MatchResult
- mkViewMatchResult :: Id -> CoreExpr -> MatchResult -> MatchResult
- mkGuardedMatchResult :: CoreExpr -> MatchResult -> MatchResult
- matchCanFail :: MatchResult -> Bool
- mkEvalMatchResult :: Id -> Type -> MatchResult -> MatchResult
- mkCoPrimCaseMatchResult :: Id -> Type -> [(Literal, MatchResult)] -> MatchResult
- mkCoAlgCaseMatchResult :: Id -> Type -> [CaseAlt DataCon] -> MatchResult
- mkCoSynCaseMatchResult :: Id -> Type -> CaseAlt PatSyn -> MatchResult
- wrapBind :: Var -> Var -> CoreExpr -> CoreExpr
- wrapBinds :: [(Var, Var)] -> CoreExpr -> CoreExpr
- mkErrorAppDs :: Id -> Type -> SDoc -> DsM CoreExpr
- mkCoreAppDs :: SDoc -> CoreExpr -> CoreExpr -> CoreExpr
- mkCoreAppsDs :: SDoc -> CoreExpr -> [CoreExpr] -> CoreExpr
- mkCastDs :: CoreExpr -> Coercion -> CoreExpr
- seqVar :: Var -> CoreExpr -> CoreExpr
- mkLHsVarPatTup :: [Id] -> LPat GhcTc
- mkLHsPatTup :: [LPat GhcTc] -> LPat GhcTc
- mkVanillaTuplePat :: [OutPat GhcTc] -> Boxity -> Pat GhcTc
- mkBigLHsVarTupId :: [Id] -> LHsExpr GhcTc
- mkBigLHsTupId :: [LHsExpr GhcTc] -> LHsExpr GhcTc
- mkBigLHsVarPatTupId :: [Id] -> LPat GhcTc
- mkBigLHsPatTupId :: [LPat GhcTc] -> LPat GhcTc
- mkSelectorBinds :: [[Tickish Id]] -> LPat GhcTc -> CoreExpr -> DsM (Id, [(Id, CoreExpr)])
- selectSimpleMatchVarL :: LPat GhcTc -> DsM Id
- selectMatchVars :: [Pat GhcTc] -> DsM [Id]
- selectMatchVar :: Pat GhcTc -> DsM Id
- mkOptTickBox :: [Tickish Id] -> CoreExpr -> CoreExpr
- mkBinaryTickBox :: Int -> Int -> CoreExpr -> DsM CoreExpr
- decideBangHood :: DynFlags -> LPat GhcTc -> LPat GhcTc
- addBang :: LPat GhcTc -> LPat GhcTc
- isTrueLHsExpr :: LHsExpr GhcTc -> Maybe (CoreExpr -> DsM CoreExpr)

# Documentation

data EquationInfo Source #

Constructors

EqnInfo |
Fields eqn_pats :: [Pat GhcTc] The patterns for an equation NB: We have already applied `decideBangHood` to these patterns. See Note [decideBangHood] in DsUtils eqn_orig :: Origin Was this equation present in the user source? This helps us avoid warnings on patterns that GHC elaborated. For instance, the pattern `-1 :: Word` gets desugared into `W# :: Word`, but we shouldn't warn about an overflowed literal for both of these cases. eqn_rhs :: MatchResult What to do after match

#### Instances

Instances details

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

firstPat :: EquationInfo -> Pat GhcTc Source #

shiftEqns :: [EquationInfo] -> [EquationInfo] Source #

data MatchResult Source #

Constructors

MatchResult CanItFail (CoreExpr -> DsM CoreExpr) |

data CanItFail Source #

Constructors

CanFail |
CantFail |

data CaseAlt a Source #

Constructors

MkCaseAlt |
Fields alt_pat :: a alt_bndrs :: [Var] alt_wrapper :: HsWrapper alt_result :: MatchResult

cantFailMatchResult :: CoreExpr -> MatchResult Source #

alwaysFailMatchResult :: MatchResult Source #

extractMatchResult :: MatchResult -> CoreExpr -> DsM CoreExpr Source #

combineMatchResults :: MatchResult -> MatchResult -> MatchResult Source #

adjustMatchResult :: DsWrapper -> MatchResult -> MatchResult Source #

adjustMatchResultDs :: (CoreExpr -> DsM CoreExpr) -> MatchResult -> MatchResult Source #

mkCoLetMatchResult :: CoreBind -> MatchResult -> MatchResult Source #

mkViewMatchResult :: Id -> CoreExpr -> MatchResult -> MatchResult Source #

mkGuardedMatchResult :: CoreExpr -> MatchResult -> MatchResult Source #

matchCanFail :: MatchResult -> Bool Source #

mkEvalMatchResult :: Id -> Type -> MatchResult -> MatchResult Source #

mkCoPrimCaseMatchResult :: Id -> Type -> [(Literal, MatchResult)] -> MatchResult Source #

mkCoAlgCaseMatchResult :: Id -> Type -> [CaseAlt DataCon] -> MatchResult Source #

mkCoSynCaseMatchResult :: Id -> Type -> CaseAlt PatSyn -> MatchResult Source #

wrapBind :: Var -> Var -> CoreExpr -> CoreExpr Source #

wrapBinds :: [(Var, Var)] -> CoreExpr -> CoreExpr Source #

mkErrorAppDs :: Id -> Type -> SDoc -> DsM CoreExpr Source #

mkCoreAppDs :: SDoc -> CoreExpr -> CoreExpr -> CoreExpr Source #

mkCoreAppsDs :: SDoc -> CoreExpr -> [CoreExpr] -> CoreExpr Source #

mkCastDs :: CoreExpr -> Coercion -> CoreExpr Source #

seqVar :: Var -> CoreExpr -> CoreExpr Source #

mkLHsVarPatTup :: [Id] -> LPat GhcTc Source #

mkLHsPatTup :: [LPat GhcTc] -> LPat GhcTc Source #

mkVanillaTuplePat :: [OutPat GhcTc] -> Boxity -> Pat GhcTc Source #

mkBigLHsVarTupId :: [Id] -> LHsExpr GhcTc Source #

mkBigLHsTupId :: [LHsExpr GhcTc] -> LHsExpr GhcTc Source #

mkBigLHsVarPatTupId :: [Id] -> LPat GhcTc Source #

mkBigLHsPatTupId :: [LPat GhcTc] -> LPat GhcTc Source #

mkSelectorBinds Source #

Arguments

:: [[Tickish Id]] | ticks to add, possibly
-> LPat GhcTc | The pattern
-> CoreExpr | Expression to which the pattern is bound
-> DsM (Id, [(Id, CoreExpr)]) | Id the rhs is bound to, for desugaring strict binds (see Note [Desugar Strict binds] in DsBinds) and all the desugared binds

selectSimpleMatchVarL :: LPat GhcTc -> DsM Id Source #

selectMatchVars :: [Pat GhcTc] -> DsM [Id] Source #

selectMatchVar :: Pat GhcTc -> DsM Id Source #

mkOptTickBox :: [Tickish Id] -> CoreExpr -> CoreExpr Source #

mkBinaryTickBox :: Int -> Int -> CoreExpr -> DsM CoreExpr Source #

decideBangHood Source #

Arguments

:: DynFlags |
-> LPat GhcTc | Original pattern
-> LPat GhcTc |

Use -XStrict to add a ! or remove a ~ See Note [decideBangHood]

addBang Source #

Arguments

:: LPat GhcTc | Original pattern
-> LPat GhcTc | Banged pattern

Unconditionally make a `Pat` strict.

isTrueLHsExpr :: LHsExpr GhcTc -> Maybe (CoreExpr -> DsM CoreExpr) Source #