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.
Moduleghc-lib-parser-9.14.1.20251220GHC2021
GHC.Core.Rules
Functions for collecting together and applying rewrite rules to a module. The CoreRule datatype itself is declared elsewhere.
Contents
Synopsis
- value lookupRule
- value matchExprs
- value ruleLhsIsMoreSpecific
- type RuleBase
- data RuleEnv
- value mkRuleEnv
- value emptyRuleEnv
- value updExternalPackageRules
- value addLocalRules
- value updLocalRules
- value emptyRuleBase
- value mkRuleBase
- value extendRuleBaseList
- value pprRuleBase
- value ruleCheckProgram
- value extendRuleInfo
- value addRuleInfo
- value addIdSpecialisations
- value addRulesToId
- value rulesOfBinds
- value getRules
- value pprRulesForUser
- value mkRule
- value mkSpecRule
- value roughTopNames
- value ruleIsOrphan
- Packageghc-lib-parser-9.14.1.20251220
- Exports26
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceRules.hs
Looking up rules
RuleBase, RuleEnv
A full rule environment which we can apply rules from. Like a RuleBase, but it also includes the set of visible orphans we use to filter out orphan rules which are not visible (even though we can see them...) See Note [Orphans] in GHC.Core
Constructors
Checking rule applications
ruleCheckProgram :: RuleOptsRule options
-> CompilerPhaseRule activation test
-> StringRule pattern
-> (Id -> [CoreRule])Rules for an Id
-> CoreProgramBindings to check in
-> SDocResulting check message
Report partial matches for rules beginning with the specified string for the purposes of error reporting
Manipulating RuleInfo rules
RuleBase and RuleEnv
Misc. CoreRule helpers
Gather all the rules for locally bound identifiers from the supplied bindings
Making rules
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
GHC.Types.Var#globalvslocal), orThe
TyConif 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