summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2009-11-05 16:50:37 +0000
committersimonpj@microsoft.com <unknown>2009-11-05 16:50:37 +0000
commit1b62d143650231ead9571ce1ebea12ac8c547a82 (patch)
tree6e188bfb1a87e5a2e1ea039c276015adfcff28d0
parent830f4b00a7299dfa742c89e13e861f310d804642 (diff)
downloadhaskell-1b62d143650231ead9571ce1ebea12ac8c547a82.tar.gz
Comments only
-rw-r--r--compiler/deSugar/Desugar.lhs2
-rw-r--r--compiler/deSugar/DsExpr.lhs4
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/deSugar/Desugar.lhs b/compiler/deSugar/Desugar.lhs
index 7e284ae949..3b30deaa2e 100644
--- a/compiler/deSugar/Desugar.lhs
+++ b/compiler/deSugar/Desugar.lhs
@@ -280,6 +280,6 @@ For the LHS of a RULE we do *not* want to desugar
[x] to build (\cn. x `c` n)
We want to leave explicit lists simply as chains
of cons's. We can achieve that slightly indirectly by
-switching off EnableRewriteRules.
+switching off EnableRewriteRules. See DsExpr.dsExplicitList.
That keeps the desugaring of list comprehensions simple too.
diff --git a/compiler/deSugar/DsExpr.lhs b/compiler/deSugar/DsExpr.lhs
index d8bd7cdeea..a58e9b4b89 100644
--- a/compiler/deSugar/DsExpr.lhs
+++ b/compiler/deSugar/DsExpr.lhs
@@ -643,6 +643,9 @@ Example: the foldr/single rule in GHC.Base
foldr k z [x] = ...
We do not want to generate a build invocation on the LHS of this RULE!
+We fix this by disabling rules in rule LHSs, and testing that
+flag here; see Note [Desugaring RULE left hand sides] in Desugar
+
To test this I've added a (static) flag -fsimple-list-literals, which
makes all list literals be generated via the simple route.
@@ -657,6 +660,7 @@ dsExplicitList elt_ty xs
; if opt_SimpleListLiterals -- -fsimple-list-literals
|| not (dopt Opt_EnableRewriteRules dflags) -- Rewrite rules off
-- Don't generate a build if there are no rules to eliminate it!
+ -- See Note [Desugaring RULE left hand sides] in Desugar
|| null dynamic_prefix -- Avoid build (\c n. foldr c n xs)!
then return $ mkListExpr elt_ty xs'
else mkBuildExpr elt_ty (mkSplitExplicitList dynamic_prefix static_suffix) }