DsUtils

ghc-8.6.3: 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_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 #

Constructors

EqnInfo |
Fields eqn_pats :: [Pat GhcTc] eqn_rhs :: MatchResult

Instances

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

firstPat :: EquationInfo -> Pat GhcTc #

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

data MatchResult #

Constructors

MatchResult CanItFail (CoreExpr -> DsM CoreExpr) |

data CanItFail #

Constructors

CanFail |
CantFail |

data CaseAlt a #

Constructors

MkCaseAlt |
Fields 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 #

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 #

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

selectMatchVar :: Pat GhcTc -> DsM Id #

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

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

decideBangHood #

Arguments

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

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

addBang #

Arguments

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

Unconditionally make a `Pat` strict.

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