ghc-8.0.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

# Documentation

data EquationInfo Source #

Constructors

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

Instances

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

firstPat :: EquationInfo -> Pat Id 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 :: DynFlags -> 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 Id Source #

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

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

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

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

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

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

mkSelectorBinds Source #

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 Source #

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

selectMatchVar :: Pat Id -> DsM Id Source #

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

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

decideBangHood Source #

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