From: simonpj@microsoft.com Date: Thu, 5 Nov 2009 16:50:37 +0000 (+0000) Subject: Comments only X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=1b62d143650231ead9571ce1ebea12ac8c547a82;p=ghc-hetmet.git Comments only --- diff --git a/compiler/deSugar/Desugar.lhs b/compiler/deSugar/Desugar.lhs index 7e284ae..3b30dea 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 d8bd7cd..a58e9b4 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) }