[project @ 2003-06-25 08:20:20 by simonpj]
authorsimonpj <unknown>
Wed, 25 Jun 2003 08:20:22 +0000 (08:20 +0000)
committersimonpj <unknown>
Wed, 25 Jun 2003 08:20:22 +0000 (08:20 +0000)
* Remove -ffoldr-build-on
  Add -rrules-off
  Document the change

* Document -fwarn-simple-patterns more

ghc/compiler/deSugar/DsListComp.lhs
ghc/compiler/main/CmdLineOpts.lhs
ghc/compiler/main/DriverState.hs
ghc/compiler/simplCore/SimplMonad.lhs
ghc/docs/users_guide/flags.sgml
ghc/docs/users_guide/using.sgml

index e9c455d..713d026 100644 (file)
@@ -22,7 +22,7 @@ import CoreSyn
 import DsMonad         -- the monadery used in the desugarer
 import DsUtils
 
-import CmdLineOpts     ( opt_FoldrBuildOn )
+import CmdLineOpts     ( opt_IgnoreIfacePragmas, opt_RulesOff )
 import CoreUtils       ( exprType, mkIfThenElse )
 import Id              ( idType )
 import Var              ( Id )
@@ -51,11 +51,16 @@ dsListComp :: [TypecheckedStmt]
           -> DsM CoreExpr
 
 dsListComp quals elt_ty
-  |  not opt_FoldrBuildOn               -- Be boring
-  || isParallelComp quals
+  |  opt_RulesOff || opt_IgnoreIfacePragmas    -- Either rules are switched off, or
+                                               --   we are ignoring what there are;
+                                               --   Either way foldr/build won't happen, so
+                                               --   use the more efficient Wadler-style desugaring
+  || isParallelComp quals                      -- Foldr-style desugaring can't handle
+                                               --   parallel list comprehensions
   = deListComp quals (mkNilExpr elt_ty)
 
-  | otherwise                           -- foldr/build lives!
+  | otherwise          -- Foldr/build should be enabled, so desugar 
+                       -- into foldrs and builds
   = newTyVarsDs [alphaTyVar]    `thenDs` \ [n_tyvar] ->
     let
        n_ty = mkTyVarTy n_tyvar
index ed8e99b..6cf2f3d 100644 (file)
@@ -73,11 +73,11 @@ module CmdLineOpts (
        -- optimisation opts
        opt_NoMethodSharing,
        opt_DoSemiTagging,
-       opt_FoldrBuildOn,
        opt_LiberateCaseThreshold,
        opt_StgDoLetNoEscapes,
        opt_UnfoldCasms,
        opt_CprOff,
+       opt_RulesOff,
        opt_UnboxStrictFields,
        opt_SimplNoPreInlining,
        opt_SimplDoEtaReduction,
@@ -107,7 +107,6 @@ module CmdLineOpts (
         opt_NoHiCheck,
        opt_OmitBlackHoling,
        opt_OmitInterfacePragmas,
-       opt_NoPruneTyDecls,
        opt_NoPruneDecls,
        opt_Static,
        opt_Unregisterised,
@@ -586,8 +585,8 @@ opt_Flatten                 = lookUp  FSLIT("-fflatten")
 -- optimisation opts
 opt_NoMethodSharing            = lookUp  FSLIT("-fno-method-sharing")
 opt_DoSemiTagging              = lookUp  FSLIT("-fsemi-tagging")
-opt_FoldrBuildOn               = lookUp  FSLIT("-ffoldr-build-on")
 opt_CprOff                     = lookUp  FSLIT("-fcpr-off")
+opt_RulesOff                   = lookUp  FSLIT("-frules-off")
        -- Switch off CPR analysis in the new demand analyser
 opt_LiberateCaseThreshold      = lookup_def_int "-fliberate-case-threshold" (10::Int)
 opt_StgDoLetNoEscapes          = lookUp  FSLIT("-flet-no-escape")
@@ -636,7 +635,6 @@ opt_UF_CheapOp  = ( 1 :: Int)       -- Only one instruction; and the args are charged
 opt_UF_DearOp   = ( 4 :: Int)
                        
 opt_NoPruneDecls               = lookUp  FSLIT("-fno-prune-decls")
-opt_NoPruneTyDecls             = lookUp  FSLIT("-fno-prune-tydecls")
 opt_Static                     = lookUp  FSLIT("-static")
 opt_Unregisterised             = lookUp  FSLIT("-funregisterised")
 opt_EmitExternalCore           = lookUp  FSLIT("-fext-core")
@@ -665,7 +663,6 @@ isStaticHscFlag f =
        "fsmp",
        "fflatten",
        "fsemi-tagging",
-       "ffoldr-build-on",
        "flet-no-escape",
        "funfold-casms-in-hi-file",
        "funbox-strict-fields",
@@ -686,11 +683,11 @@ isStaticHscFlag f =
        "fexcess-precision",
        "funfolding-update-in-place",
        "fno-prune-decls",
-       "fno-prune-tydecls",
        "static",
        "funregisterised",
        "fext-core",
        "frule-check",
+       "frules-off",
        "fcpr-off"
        ]
   || any (flip prefixMatch f) [
index 0e22c01..c24e569 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: DriverState.hs,v 1.93 2003/06/24 12:56:44 stolz Exp $
+-- $Id: DriverState.hs,v 1.94 2003/06/25 08:20:21 simonpj Exp $
 --
 -- Settings for the driver
 --
@@ -213,7 +213,6 @@ hsc_minusNoO_flags =
 hsc_minusO_flags =
   [ 
        "-fignore-asserts",
-       "-ffoldr-build-on",
         "-fdo-eta-reduction",
        "-fdo-lambda-eta-expansion",
        "-fcase-merge",
index 09c8916..afe7289 100644 (file)
@@ -77,7 +77,7 @@ import BasicTypes     ( TopLevelFlag, isTopLevel, isLoopBreaker,
                        )
 import CmdLineOpts     ( SimplifierSwitch(..), SimplifierMode(..),
                          DynFlags, DynFlag(..), dopt, 
-                         opt_PprStyle_Debug, opt_HistorySize, opt_SimplNoPreInlining,
+                         opt_PprStyle_Debug, opt_HistorySize, opt_SimplNoPreInlining, opt_RulesOff
                        )
 import Unique          ( Unique )
 import Outputable
@@ -926,6 +926,8 @@ activeInline env id occ
 activeRule :: SimplEnv -> Maybe (Activation -> Bool)
 -- Nothing => No rules at all
 activeRule env
+  | opt_RulesOff = Nothing
+  | otherwise
   = case getMode env of
        SimplGently  -> Just isAlwaysActive
                        -- Used to be Nothing (no rules in gentle mode)
index 8a1f164..afd7622 100644 (file)
            </row>
 
            <row>
-             <entry><option>-ffoldr-build-on</option></entry>
-             <entry>Enable foldr-build optimisation</entry>
+             <entry><option>-frules-off</option></entry>
+             <entry>Switch off all rewrite rules</entry>
              <entry>static</entry>
-             <entry><option>-fno-foldr-build-on</option></entry>
+             <entry><option>-frules-off</option></entry>
            </row>
 
            <row>
index d3d205a..e1222c0 100644 (file)
@@ -1066,6 +1066,20 @@ f "2"    = 2
          patterns that can fail, eg. <literal>\(x:xs)->...</literal>.
          Normally, these aren't treated as incomplete patterns by
          <option>-fwarn-incomplete-patterns</option>.</para>
+         <para>``Lambda-bound patterns'' includes all places where there is a single pattern,
+           including list comprehensions and do-notation.  In these cases, a pattern-match 
+           failure is quite legitimate, and triggers filtering (list comprehensions) or
+           the monad <literal>fail</literal> operation (monads). For example:
+           <programlisting>
+             f :: [Maybe a] -> [a]
+             f xs = [y | Just y <- xs]
+             </programlisting>
+           Switching on <option>-fwarn-simple-patterns</option> will elicit warnings about
+           these probably-innocent cases, which is why the flag is off by default. </para>
+         <para> The <literal>deriving( Read )</literal> mechanism produces monadic code with
+           pattern matches, so you will also get misleading warnings about the compiler-generated
+           code.  (This is arguably a Bad Thing, but it's awkward to fix.)</para>
+
        </listitem>
       </varlistentry>