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 )
-> 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
-- optimisation opts
opt_NoMethodSharing,
opt_DoSemiTagging,
- opt_FoldrBuildOn,
opt_LiberateCaseThreshold,
opt_StgDoLetNoEscapes,
opt_UnfoldCasms,
opt_CprOff,
+ opt_RulesOff,
opt_UnboxStrictFields,
opt_SimplNoPreInlining,
opt_SimplDoEtaReduction,
opt_NoHiCheck,
opt_OmitBlackHoling,
opt_OmitInterfacePragmas,
- opt_NoPruneTyDecls,
opt_NoPruneDecls,
opt_Static,
opt_Unregisterised,
-- 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")
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")
"fsmp",
"fflatten",
"fsemi-tagging",
- "ffoldr-build-on",
"flet-no-escape",
"funfold-casms-in-hi-file",
"funbox-strict-fields",
"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) [
-----------------------------------------------------------------------------
--- $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
--
hsc_minusO_flags =
[
"-fignore-asserts",
- "-ffoldr-build-on",
"-fdo-eta-reduction",
"-fdo-lambda-eta-expansion",
"-fcase-merge",
)
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
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)
</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>
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>