summaryrefslogtreecommitdiff
path: root/compiler/specialise/Rules.lhs
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2008-08-21 12:31:00 +0000
committersimonpj@microsoft.com <unknown>2008-08-21 12:31:00 +0000
commit10f18550c3684368b9d8e5b7adcccc14994cf170 (patch)
tree0d7e11fe43ed99441cf2d9ac74f3921962b89f3d /compiler/specialise/Rules.lhs
parent0069a47ad1a539c894f66163cf30c7d98dc9b016 (diff)
downloadhaskell-10f18550c3684368b9d8e5b7adcccc14994cf170.tar.gz
Make rule printing wobble less
a) When generating specialisations, include the types in the name of the rule, to avoid having rules with duplicate names. (The rule name is used to put rules in canonical order for fingerprinting.) b) In Specialise and SpecConstr use a new function Rules.pprRulesForUser to print rules in canonical order. This reduces unnecessary wobbling in test output, notably in T2486
Diffstat (limited to 'compiler/specialise/Rules.lhs')
-rw-r--r--compiler/specialise/Rules.lhs19
1 files changed, 17 insertions, 2 deletions
diff --git a/compiler/specialise/Rules.lhs b/compiler/specialise/Rules.lhs
index 0303833726..66442ebb55 100644
--- a/compiler/specialise/Rules.lhs
+++ b/compiler/specialise/Rules.lhs
@@ -29,7 +29,7 @@ module Rules (
addIdSpecialisations,
-- * Misc. CoreRule helpers
- rulesOfBinds,
+ rulesOfBinds, pprRulesForUser,
lookupRule, mkLocalRule, roughTopNames
) where
@@ -152,6 +152,22 @@ ruleCantMatch (t : ts) (a : as) = ruleCantMatch ts as
ruleCantMatch ts as = False
\end{code}
+\begin{code}
+pprRulesForUser :: [CoreRule] -> SDoc
+-- (a) tidy the rules
+-- (b) sort them into order based on the rule name
+-- (c) suppress uniques (unless -dppr-debug is on)
+-- This combination makes the output stable so we can use in testing
+-- It's here rather than in PprCore because it calls tidyRules
+pprRulesForUser rules
+ = withPprStyle defaultUserStyle $
+ pprRules $
+ sortLe le_rule $
+ tidyRules emptyTidyEnv rules
+ where
+ le_rule r1 r2 = ru_name r1 <= ru_name r2
+\end{code}
+
%************************************************************************
%* *
@@ -168,7 +184,6 @@ mkSpecInfo rules = SpecInfo rules (rulesFreeVars rules)
extendSpecInfo :: SpecInfo -> [CoreRule] -> SpecInfo
extendSpecInfo (SpecInfo rs1 fvs1) rs2
= SpecInfo (rs2 ++ rs1) (rulesFreeVars rs2 `unionVarSet` fvs1)
-
addSpecInfo :: SpecInfo -> SpecInfo -> SpecInfo
addSpecInfo (SpecInfo rs1 fvs1) (SpecInfo rs2 fvs2)
= SpecInfo (rs1 ++ rs2) (fvs1 `unionVarSet` fvs2)