ghc-6.10.4: The GHC APIContentsIndex
Rules
Contents
RuleBase
Constructing
Checking rule applications
Manipulating SpecInfo rules
Misc. CoreRule helpers
Description
Functions for collecting together and applying rewrite rules to a module. The CoreRule datatype itself is declared elsewhere.
Synopsis
type RuleBase = NameEnv [CoreRule]
emptyRuleBase
mkRuleBase :: [CoreRule] -> RuleBase
extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase
unionRuleBase :: RuleBase -> RuleBase -> RuleBase
pprRuleBase :: RuleBase -> SDoc
ruleCheckProgram :: CompilerPhase -> String -> RuleBase -> [CoreBind] -> 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) -> InScopeSet -> Id -> [CoreExpr] -> [CoreRule] -> Maybe (CoreRule, CoreExpr)
mkLocalRule :: RuleName -> Activation -> Name -> [CoreBndr] -> [CoreExpr] -> CoreExpr -> CoreRule
roughTopNames :: [CoreExpr] -> [Maybe Name]
RuleBase
type RuleBase = NameEnv [CoreRule]
Gathers a collection of CoreRules. Maps (the name of) an Id to its rules
Constructing
emptyRuleBase
mkRuleBase :: [CoreRule] -> RuleBase
extendRuleBaseList :: RuleBase -> [CoreRule] -> RuleBase
unionRuleBase :: RuleBase -> RuleBase -> RuleBase
pprRuleBase :: RuleBase -> SDoc
Checking rule applications
ruleCheckProgram
:: CompilerPhasePhase to check in
-> StringRule pattern
-> RuleBaseDatabase of rules
-> [CoreBind]Bindings to check in
-> SDocResulting check message
Report partial matches for rules beginning with the specified string for the purposes of error reporting
Manipulating SpecInfo rules
mkSpecInfo :: [CoreRule] -> SpecInfo
Make a SpecInfo containing a number of CoreRules, suitable for putting into an IdInfo
extendSpecInfo :: SpecInfo -> [CoreRule] -> SpecInfo
addSpecInfo :: SpecInfo -> SpecInfo -> SpecInfo
addIdSpecialisations :: Id -> [CoreRule] -> Id
Misc. CoreRule helpers
rulesOfBinds :: [CoreBind] -> [CoreRule]
Gather all the rules for locally bound identifiers from the supplied bindings
getRules :: RuleBase -> Id -> [CoreRule]
pprRulesForUser :: [CoreRule] -> SDoc
lookupRule :: (Activation -> Bool) -> InScopeSet -> Id -> [CoreExpr] -> [CoreRule] -> Maybe (CoreRule, CoreExpr)
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.
mkLocalRule :: RuleName -> Activation -> Name -> [CoreBndr] -> [CoreExpr] -> CoreExpr -> CoreRule
Used to make CoreRule for an Id defined in the module being compiled. See also CoreRule
roughTopNames :: [CoreExpr] -> [Maybe Name]

Find the "top" free names of several expressions. Such names are either:

1. The function finally being applied to in an application chain (if that name is a GlobalId: see Var), or

2. The TyCon if the expression is a Type

This is used for the fast-match-check for rules; if the top names don't match, the rest can't

Produced by Haddock version 2.4.2