- (orphan_rules, rules_for_locals) = partition isOrphanRule better_rules
- -- Get the rules for locally-defined Ids out of the RuleBase
- -- If we miss any rules for Ids defined here, then we end up
- -- giving the local decl a new Unique (because the in-scope-set is (hackily) the
- -- same as the non-local-rule-id set, so the Id looks as if it's in scope
- -- and hence should be cloned), and now the binding for the class method
- -- doesn't have the same Unique as the one in the Class and the tc-env
- -- Example: class Foo a where
- -- op :: a -> a
- -- {-# RULES "op" op x = x #-}
-
- -- NB: we assume that the imported rules dont include
- -- rules for Ids in this module; if there is, the above bad things may happen
-
- pkg_rule_base = eps_rule_base eps
- hpt_rule_base = extendRuleBaseList pkg_rule_base home_pkg_rules
- imp_rule_base = extendRuleBaseList hpt_rule_base orphan_rules
-
- -- Update the binders in the local bindings with the lcoal rules
- -- Update the binders of top-level bindings by
- -- attaching the rules for each locally-defined Id to that Id.