ghc-8.2.2: 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 Id]
  - eqn_rhs :: MatchResult
  }
- firstPat :: EquationInfo -> Pat Id
- 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 :: DynFlags -> 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 Id
- mkLHsPatTup :: [LPat Id] -> LPat Id
- mkVanillaTuplePat :: [OutPat Id] -> Boxity -> Pat Id
- mkBigLHsVarTupId :: [Id] -> LHsExpr Id
- mkBigLHsTupId :: [LHsExpr Id] -> LHsExpr Id
- mkBigLHsVarPatTupId :: [Id] -> LPat Id
- mkBigLHsPatTupId :: [LPat Id] -> LPat Id
- mkSelectorBinds :: [[Tickish Id]] -> LPat Id -> CoreExpr -> DsM (Id, [(Id, CoreExpr)])
- selectSimpleMatchVarL :: LPat Id -> DsM Id
- selectMatchVars :: [Pat Id] -> DsM [Id]
- selectMatchVar :: Pat Id -> DsM Id
- mkOptTickBox :: [Tickish Id] -> CoreExpr -> CoreExpr
- mkBinaryTickBox :: Int -> Int -> CoreExpr -> DsM CoreExpr
- decideBangHood :: DynFlags -> LPat id -> LPat id
- addBang :: LPat id -> LPat id

# Documentation

data EquationInfo #

Constructors

EqnInfo |

Fields

- eqn_pats :: [Pat Id]
- eqn_rhs :: MatchResult

Instances

Outputable EquationInfo # |
Methods ppr :: EquationInfo -> SDoc # pprPrec :: Rational -> EquationInfo -> SDoc #

firstPat :: EquationInfo -> Pat Id #

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 :: DynFlags -> 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 Id #

mkLHsPatTup :: [LPat Id] -> LPat Id #

mkVanillaTuplePat :: [OutPat Id] -> Boxity -> Pat Id #

mkBigLHsVarTupId :: [Id] -> LHsExpr Id #

mkBigLHsTupId :: [LHsExpr Id] -> LHsExpr Id #

mkBigLHsVarPatTupId :: [Id] -> LPat Id #

mkBigLHsPatTupId :: [LPat Id] -> LPat Id #

mkSelectorBinds #

Arguments

:: [[Tickish Id]] | ticks to add, possibly
-> LPat Id | 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 Id -> DsM Id #

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

selectMatchVar :: Pat Id -> DsM Id #

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

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

decideBangHood #

Arguments

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

Use -XStrict to add a ! or remove a ~

Examples: ~pat => pat -- when -XStrict (even if pat = ~pat') !pat => !pat -- always pat => !pat -- when -XStrict pat => pat -- otherwise

addBang #

Arguments

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

Unconditionally make a `Pat` strict.