Safe Haskell | Safe-Infered |
---|
Functions for collecting together and applying rewrite rules to a module.
The CoreRule
datatype itself is declared elsewhere.
- type RuleBase = NameEnv [CoreRule]
- emptyRuleBase :: RuleBase
- mkRuleBase :: [CoreRule] -> RuleBase
- extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase
- unionRuleBase :: RuleBase -> RuleBase -> RuleBase
- pprRuleBase :: RuleBase -> SDoc
- ruleCheckProgram :: CompilerPhase -> String -> RuleBase -> CoreProgram -> SDoc
- mkSpecInfo :: [CoreRule] -> SpecInfo
- extendSpecInfo :: SpecInfo -> [CoreRule] -> SpecInfo
- addSpecInfo :: SpecInfo -> SpecInfo -> SpecInfo
- addIdSpecialisations :: Id -> [CoreRule] -> Id
- rulesOfBinds :: [CoreBind] -> [CoreRule]
- getRules :: RuleBase -> Id -> [CoreRule]
- pprRulesForUser :: [CoreRule] -> SDoc
- lookupRule :: (Activation -> Bool) -> IdUnfoldingFun -> InScopeSet -> Id -> [CoreExpr] -> [CoreRule] -> Maybe (CoreRule, CoreExpr)
- mkRule :: Bool -> Bool -> RuleName -> Activation -> Name -> [CoreBndr] -> [CoreExpr] -> CoreExpr -> CoreRule
- roughTopNames :: [CoreExpr] -> [Maybe Name]
RuleBase
Constructing
mkRuleBase :: [CoreRule] -> RuleBaseSource
extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBaseSource
unionRuleBase :: RuleBase -> RuleBase -> RuleBaseSource
pprRuleBase :: RuleBase -> SDocSource
Checking rule applications
:: CompilerPhase | Rule activation test |
-> String | Rule pattern |
-> RuleBase | Database of rules |
-> CoreProgram | Bindings to check in |
-> SDoc | Resulting check message |
Report partial matches for rules beginning with the specified string for the purposes of error reporting
Manipulating SpecInfo
rules
mkSpecInfo :: [CoreRule] -> SpecInfoSource
extendSpecInfo :: SpecInfo -> [CoreRule] -> SpecInfoSource
addSpecInfo :: SpecInfo -> SpecInfo -> SpecInfoSource
addIdSpecialisations :: Id -> [CoreRule] -> IdSource
Misc. CoreRule helpers
rulesOfBinds :: [CoreBind] -> [CoreRule]Source
Gather all the rules for locally bound identifiers from the supplied bindings
pprRulesForUser :: [CoreRule] -> SDocSource
lookupRule :: (Activation -> Bool) -> IdUnfoldingFun -> InScopeSet -> Id -> [CoreExpr] -> [CoreRule] -> Maybe (CoreRule, CoreExpr)Source
The main rule matching function. Attempts to apply all (active) supplied rules to this instance of an application in a given context, returning the rule applied and the resulting expression if successful.
mkRule :: Bool -> Bool -> RuleName -> Activation -> Name -> [CoreBndr] -> [CoreExpr] -> CoreExpr -> CoreRuleSource
roughTopNames :: [CoreExpr] -> [Maybe Name]Source
Find the "top" free names of several expressions. Such names are either:
- The function finally being applied to in an application chain (if that name is a GlobalId: see Var), or
- The
TyCon
if the expression is aType
This is used for the fast-match-check for rules; if the top names don't match, the rest can't