\begin{code}
module Rules (
- RuleBase, emptyRuleBase, extendRuleBase, extendRuleBaseList, pprRuleBase,
- addRuleBaseFVs,
+ RuleBase, emptyRuleBase,
+ extendRuleBase, extendRuleBaseList, addRuleBaseFVs,
+ ruleBaseIds, ruleBaseFVs,
+ pprRuleBase,
lookupRule, addRule, addIdSpecialisations
) where
substEnv, setSubstEnv, emptySubst, isInScope,
bindSubstList, unBindSubstList, substInScope, uniqAway
)
-import Id ( Id, idUnfolding, zapLamIdInfo,
- idSpecialisation, setIdSpecialisation
- )
-import Var ( isTyVar, isId )
+import Id ( Id, idUnfolding, idSpecialisation, setIdSpecialisation )
+import Var ( isId )
import VarSet
import VarEnv
import Type ( mkTyVarTy )
----------------------------------------
match_ty ty1 ty2 tpl_vars kont subst
- = case Unify.match ty1 ty2 tpl_vars Just (substEnv subst) of
+ = case Unify.match False {- for now: KSW 2000-10 -} ty1 ty2 tpl_vars Just (substEnv subst) of
Nothing -> match_fail
Just senv' -> kont (setSubstEnv subst senv')
new_is_more_specific rule = maybeToBool (matchRule tpl_var_set rule tpl_args)
-addIdSpecialisations :: Id -> [([CoreBndr], [CoreExpr], CoreExpr)] -> Id
-addIdSpecialisations id spec_stuff
- = setIdSpecialisation id new_rules
+addIdSpecialisations :: Id -> [CoreRule] -> Id
+addIdSpecialisations id rules
+ = setIdSpecialisation id new_specs
where
- rule_name = _PK_ ("SPEC " ++ showSDoc (ppr id))
- new_rules = foldr add (idSpecialisation id) spec_stuff
- add (vars, args, rhs) rules = addRule rules id (Rule rule_name vars args rhs)
+ new_specs = foldr add (idSpecialisation id) rules
+ add rule rules = addRule rules id rule
\end{code}
-- This representation is a bit cute, and I wonder if we should
-- change it to use (IdEnv CoreRule) which seems a bit more natural
+ruleBaseIds (RuleBase ids _) = ids
+ruleBaseFVs (RuleBase _ fvs) = fvs
+
emptyRuleBase = RuleBase emptyVarSet emptyVarSet
addRuleBaseFVs :: RuleBase -> IdSet -> RuleBase