Safe Haskell | None |
---|---|
Language | Haskell2010 |
Utility functions for constructing Core syntax, principally for desugaring
Synopsis
- data EquationInfo = EqnInfo {
- eqn_pats :: [Pat GhcTc]
- eqn_orig :: Origin
- eqn_rhs :: MatchResult CoreExpr
- firstPat :: EquationInfo -> Pat GhcTc
- shiftEqns :: Functor f => f EquationInfo -> f EquationInfo
- data MatchResult a
- = MR_Infallible (DsM a)
- | MR_Fallible (CoreExpr -> DsM a)
- data CaseAlt a = MkCaseAlt {
- alt_pat :: a
- alt_bndrs :: [Var]
- alt_wrapper :: HsWrapper
- alt_result :: MatchResult CoreExpr
- cantFailMatchResult :: CoreExpr -> MatchResult CoreExpr
- alwaysFailMatchResult :: MatchResult CoreExpr
- extractMatchResult :: MatchResult CoreExpr -> CoreExpr -> DsM CoreExpr
- combineMatchResults :: MatchResult CoreExpr -> MatchResult CoreExpr -> MatchResult CoreExpr
- adjustMatchResultDs :: (a -> DsM b) -> MatchResult a -> MatchResult b
- shareFailureHandler :: MatchResult CoreExpr -> MatchResult CoreExpr
- dsHandleMonadicFailure :: HsStmtContext GhcRn -> LPat GhcTc -> MatchResult CoreExpr -> FailOperator GhcTc -> DsM CoreExpr
- mkCoLetMatchResult :: CoreBind -> MatchResult CoreExpr -> MatchResult CoreExpr
- mkViewMatchResult :: Id -> CoreExpr -> MatchResult CoreExpr -> MatchResult CoreExpr
- mkGuardedMatchResult :: CoreExpr -> MatchResult CoreExpr -> MatchResult CoreExpr
- matchCanFail :: MatchResult a -> Bool
- mkEvalMatchResult :: Id -> Type -> MatchResult CoreExpr -> MatchResult CoreExpr
- mkCoPrimCaseMatchResult :: Id -> Type -> [(Literal, MatchResult CoreExpr)] -> MatchResult CoreExpr
- mkCoAlgCaseMatchResult :: Id -> Type -> NonEmpty (CaseAlt DataCon) -> MatchResult CoreExpr
- mkCoSynCaseMatchResult :: Id -> Type -> CaseAlt PatSyn -> MatchResult CoreExpr
- 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
- mkFailExpr :: HsMatchContext GhcRn -> Type -> DsM CoreExpr
- seqVar :: Var -> CoreExpr -> CoreExpr
- mkLHsPatTup :: [LPat GhcTc] -> LPat GhcTc
- mkVanillaTuplePat :: [LPat GhcTc] -> Boxity -> Pat GhcTc
- mkBigLHsVarTupId :: [Id] -> LHsExpr GhcTc
- mkBigLHsTupId :: [LHsExpr GhcTc] -> LHsExpr GhcTc
- mkBigLHsVarPatTupId :: [Id] -> LPat GhcTc
- mkBigLHsPatTupId :: [LPat GhcTc] -> LPat GhcTc
- mkSelectorBinds :: [[CoreTickish]] -> LPat GhcTc -> CoreExpr -> DsM (Id, [(Id, CoreExpr)])
- selectSimpleMatchVarL :: Mult -> LPat GhcTc -> DsM Id
- selectMatchVars :: [(Mult, Pat GhcTc)] -> DsM [Id]
- selectMatchVar :: Mult -> Pat GhcTc -> DsM Id
- mkOptTickBox :: [CoreTickish] -> CoreExpr -> CoreExpr
- mkBinaryTickBox :: Int -> Int -> CoreExpr -> DsM CoreExpr
- decideBangHood :: DynFlags -> LPat GhcTc -> LPat GhcTc
- isTrueLHsExpr :: LHsExpr GhcTc -> Maybe (CoreExpr -> DsM CoreExpr)
Documentation
data EquationInfo Source #
EqnInfo | |
|
Instances
Outputable EquationInfo Source # | |
Defined in GHC.HsToCore.Monad ppr :: EquationInfo -> SDoc |
firstPat :: EquationInfo -> Pat GhcTc Source #
shiftEqns :: Functor f => f EquationInfo -> f EquationInfo Source #
data MatchResult a Source #
This is a value of type a with potentially a CoreExpr-shaped hole in it. This is used to deal with cases where we are potentially handling pattern match failure, and want to later specify how failure is handled.
MR_Infallible (DsM a) | We represent the case where there is no hole without a function from
|
MR_Fallible (CoreExpr -> DsM a) |
Instances
Functor MatchResult Source # | |
Defined in GHC.HsToCore.Monad fmap :: (a -> b) -> MatchResult a -> MatchResult b # (<$) :: a -> MatchResult b -> MatchResult a # | |
Applicative MatchResult Source # | Product is an "or" on falliblity---the combined match result is infallible only if the left and right argument match results both were. This is useful for combining a bunch of alternatives together and then
getting the overall falliblity of the entire group. See |
Defined in GHC.HsToCore.Monad pure :: a -> MatchResult a # (<*>) :: MatchResult (a -> b) -> MatchResult a -> MatchResult b # liftA2 :: (a -> b -> c) -> MatchResult a -> MatchResult b -> MatchResult c # (*>) :: MatchResult a -> MatchResult b -> MatchResult b # (<*) :: MatchResult a -> MatchResult b -> MatchResult a # |
MkCaseAlt | |
|
cantFailMatchResult :: CoreExpr -> MatchResult CoreExpr Source #
alwaysFailMatchResult :: MatchResult CoreExpr Source #
extractMatchResult :: MatchResult CoreExpr -> CoreExpr -> DsM CoreExpr Source #
combineMatchResults :: MatchResult CoreExpr -> MatchResult CoreExpr -> MatchResult CoreExpr Source #
adjustMatchResultDs :: (a -> DsM b) -> MatchResult a -> MatchResult b Source #
shareFailureHandler :: MatchResult CoreExpr -> MatchResult CoreExpr Source #
dsHandleMonadicFailure :: HsStmtContext GhcRn -> LPat GhcTc -> MatchResult CoreExpr -> FailOperator GhcTc -> DsM CoreExpr Source #
mkCoLetMatchResult :: CoreBind -> MatchResult CoreExpr -> MatchResult CoreExpr Source #
mkViewMatchResult :: Id -> CoreExpr -> MatchResult CoreExpr -> MatchResult CoreExpr Source #
mkGuardedMatchResult :: CoreExpr -> MatchResult CoreExpr -> MatchResult CoreExpr Source #
matchCanFail :: MatchResult a -> Bool Source #
mkEvalMatchResult :: Id -> Type -> MatchResult CoreExpr -> MatchResult CoreExpr Source #
mkCoPrimCaseMatchResult :: Id -> Type -> [(Literal, MatchResult CoreExpr)] -> MatchResult CoreExpr Source #
mkCoSynCaseMatchResult :: Id -> Type -> CaseAlt PatSyn -> MatchResult CoreExpr Source #
mkCoreAppDs :: SDoc -> CoreExpr -> CoreExpr -> CoreExpr Source #
mkCoreAppsDs :: SDoc -> CoreExpr -> [CoreExpr] -> CoreExpr Source #
mkFailExpr :: HsMatchContext GhcRn -> Type -> DsM CoreExpr Source #
mkLHsPatTup :: [LPat GhcTc] -> LPat GhcTc Source #
mkVanillaTuplePat :: [LPat 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 #
:: [[CoreTickish]] | 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 GHC.HsToCore.Binds) and all the desugared binds |
mkOptTickBox :: [CoreTickish] -> CoreExpr -> CoreExpr Source #
:: DynFlags | |
-> LPat GhcTc | Original pattern |
-> LPat GhcTc |
Use -XStrict to add a ! or remove a ~ See Note [decideBangHood]
isTrueLHsExpr :: LHsExpr GhcTc -> Maybe (CoreExpr -> DsM CoreExpr) Source #