Comments only
authorsimonpj@microsoft.com <unknown>
Thu, 5 Nov 2009 16:50:37 +0000 (16:50 +0000)
committersimonpj@microsoft.com <unknown>
Thu, 5 Nov 2009 16:50:37 +0000 (16:50 +0000)
compiler/deSugar/Desugar.lhs
compiler/deSugar/DsExpr.lhs

index 7e284ae..3b30dea 100644 (file)
@@ -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.
index d8bd7cd..a58e9b4 100644 (file)
@@ -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) }