summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2008-08-26 12:21:21 +0000
committersimonpj@microsoft.com <unknown>2008-08-26 12:21:21 +0000
commit24b1e13657c3e06e7c97eeab9a6c4f2a0cdd9193 (patch)
tree4ef829ad3364d1c739e40786d50c34539a9dece2 /compiler
parent8b4b45b96466be65f4e23c46c20c2199b6ae6c29 (diff)
downloadhaskell-24b1e13657c3e06e7c97eeab9a6c4f2a0cdd9193.tar.gz
Fix flaggery for RULES (cf Trac #2497)
This patch executes the plan described in the discussion in Trac #2497. Specficially: * Inside a RULE, switch on the forall-as-keyword in the lexer, unconditionally. (Actually this is done by an earlier patch.) * Merge the -XScopedTypeVariables and -XPatternSignatures flags, and deprecate the latter. Distinguishing them isn't senseless, but it's jolly confusing. * Inside a RULE, switch on -XScopedTypeVariables unconditionally. * Change -frewrite-rules to -fenable-rewrite-rules; deprecate the former. Internally the DynFlag is now Opt_EnableRewriteRules. There's a test in typecheck/should_compile/T2497.hs
Diffstat (limited to 'compiler')
-rw-r--r--compiler/deSugar/DsExpr.lhs2
-rw-r--r--compiler/deSugar/DsListComp.lhs2
-rw-r--r--compiler/ghc.cabal2
-rw-r--r--compiler/main/DynFlags.hs23
-rw-r--r--compiler/rename/RnPat.lhs4
-rw-r--r--compiler/rename/RnSource.lhs4
-rw-r--r--compiler/simplCore/SimplUtils.lhs2
-rw-r--r--compiler/typecheck/TcDeriv.lhs4
8 files changed, 27 insertions, 16 deletions
diff --git a/compiler/deSugar/DsExpr.lhs b/compiler/deSugar/DsExpr.lhs
index eed7f87d8f..f152ff5725 100644
--- a/compiler/deSugar/DsExpr.lhs
+++ b/compiler/deSugar/DsExpr.lhs
@@ -564,7 +564,7 @@ dsExplicitList :: PostTcType -> [LHsExpr Id] -> DsM CoreExpr
dsExplicitList elt_ty xs = do
dflags <- getDOptsDs
xs' <- mapM dsLExpr xs
- if not (dopt Opt_RewriteRules dflags)
+ if not (dopt Opt_EnableRewriteRules dflags)
then return $ mkListExpr elt_ty xs'
else mkBuildExpr elt_ty (mkSplitExplicitList (thisPackage dflags) xs')
where
diff --git a/compiler/deSugar/DsListComp.lhs b/compiler/deSugar/DsListComp.lhs
index 2bd1a6d741..bdbe65ee7e 100644
--- a/compiler/deSugar/DsListComp.lhs
+++ b/compiler/deSugar/DsListComp.lhs
@@ -56,7 +56,7 @@ dsListComp lquals body elt_ty = do
dflags <- getDOptsDs
let quals = map unLoc lquals
- if not (dopt Opt_RewriteRules dflags) || dopt Opt_IgnoreInterfacePragmas dflags
+ if not (dopt Opt_EnableRewriteRules dflags) || dopt Opt_IgnoreInterfacePragmas dflags
-- 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
diff --git a/compiler/ghc.cabal b/compiler/ghc.cabal
index b1de64ef69..437ebc2809 100644
--- a/compiler/ghc.cabal
+++ b/compiler/ghc.cabal
@@ -85,7 +85,7 @@ Library
Extensions: CPP, MagicHash, UnboxedTuples, PatternGuards,
ForeignFunctionInterface, EmptyDataDecls,
TypeSynonymInstances, MultiParamTypeClasses,
- FlexibleInstances, Rank2Types, PatternSignatures
+ FlexibleInstances, Rank2Types, ScopedTypeVariables
Include-Dirs: . parser utils
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 062443dde9..a3330e7491 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -229,7 +229,6 @@ data DynFlag
| Opt_MagicHash
| Opt_EmptyDataDecls
| Opt_KindSignatures
- | Opt_PatternSignatures
| Opt_ParallelListComp
| Opt_TransformListComp
| Opt_GeneralizedNewtypeDeriving
@@ -261,7 +260,7 @@ data DynFlag
| Opt_UnboxStrictFields
| Opt_MethodSharing
| Opt_DictsCheap
- | Opt_RewriteRules
+ | Opt_EnableRewriteRules -- Apply rewrite rules during simplification
| Opt_Vectorise
| Opt_RegsGraph -- do graph coloring register allocation
| Opt_RegsIterative -- do iterative coalescing graph coloring register allocation
@@ -794,8 +793,8 @@ optLevelFlags
, ([0], Opt_OmitInterfacePragmas)
, ([1,2], Opt_IgnoreAsserts)
- , ([1,2], Opt_RewriteRules) -- Off for -O0; see Note [Scoping for Builtin rules]
- -- in PrelRules
+ , ([1,2], Opt_EnableRewriteRules) -- Off for -O0; see Note [Scoping for Builtin rules]
+ -- in PrelRules
, ([1,2], Opt_DoEtaReduction)
, ([1,2], Opt_CaseMerge)
, ([1,2], Opt_Strictness)
@@ -1470,6 +1469,12 @@ deprecatedForLanguage lang turn_on
flag | turn_on = lang
| otherwise = "No"++lang
+useInstead :: String -> Bool -> Deprecated
+useInstead flag turn_on
+ = Deprecated ("Use -f" ++ no ++ flag ++ " instead")
+ where
+ no = if turn_on then "" else "no-"
+
-- | These @-f\<blah\>@ flags can all be reversed with @-fno-\<blah\>@
fFlags :: [(String, DynFlag, Bool -> Deprecated)]
fFlags = [
@@ -1518,7 +1523,8 @@ fFlags = [
( "print-bind-result", Opt_PrintBindResult, const Supported ),
( "force-recomp", Opt_ForceRecomp, const Supported ),
( "hpc-no-auto", Opt_Hpc_No_Auto, const Supported ),
- ( "rewrite-rules", Opt_RewriteRules, const Supported ),
+ ( "rewrite-rules", Opt_EnableRewriteRules, useInstead "enable-rewrite-rules" ),
+ ( "enable-rewrite-rules", Opt_EnableRewriteRules, const Supported ),
( "break-on-exception", Opt_BreakOnException, const Supported ),
( "break-on-error", Opt_BreakOnError, const Supported ),
( "print-evld-with-show", Opt_PrintEvldWithShow, const Supported ),
@@ -1583,7 +1589,6 @@ xFlags = [
( "PolymorphicComponents", Opt_PolymorphicComponents, const Supported ),
( "ExistentialQuantification", Opt_ExistentialQuantification, const Supported ),
( "KindSignatures", Opt_KindSignatures, const Supported ),
- ( "PatternSignatures", Opt_PatternSignatures, const Supported ),
( "EmptyDataDecls", Opt_EmptyDataDecls, const Supported ),
( "ParallelListComp", Opt_ParallelListComp, const Supported ),
( "TransformListComp", Opt_TransformListComp, const Supported ),
@@ -1620,6 +1625,11 @@ xFlags = [
( "ExtendedDefaultRules", Opt_ExtendedDefaultRules, const Supported ),
( "ImplicitParams", Opt_ImplicitParams, const Supported ),
( "ScopedTypeVariables", Opt_ScopedTypeVariables, const Supported ),
+
+ -- -XPatternSignatures is deprecated; now -XScopedTypeVariables enables pattern signatures
+ ( "PatternSignatures", Opt_ScopedTypeVariables,
+ deprecatedForLanguage "ScopedTypeVariables" ),
+
( "UnboxedTuples", Opt_UnboxedTuples, const Supported ),
( "StandaloneDeriving", Opt_StandaloneDeriving, const Supported ),
( "DeriveDataTypeable", Opt_DeriveDataTypeable, const Supported ),
@@ -1675,7 +1685,6 @@ glasgowExtsFlags = [
, Opt_ParallelListComp
, Opt_EmptyDataDecls
, Opt_KindSignatures
- , Opt_PatternSignatures
, Opt_GeneralizedNewtypeDeriving
, Opt_TypeFamilies ]
diff --git a/compiler/rename/RnPat.lhs b/compiler/rename/RnPat.lhs
index 584c2870cd..18f3dd5d85 100644
--- a/compiler/rename/RnPat.lhs
+++ b/compiler/rename/RnPat.lhs
@@ -212,7 +212,7 @@ rnLPatAndThen var@(NM varf) (L loc p) cont =
-- (e.g. in the pattern (x, x -> y) x needs to be bound in the rhs of the tuple)
SigPatIn pat ty -> do
- patsigs <- doptM Opt_PatternSignatures
+ patsigs <- doptM Opt_ScopedTypeVariables
if patsigs
then rnLPatAndThen var pat
(\ pat' -> do { (ty', fvs1) <- rnHsTypeFVs tvdoc ty
@@ -580,7 +580,7 @@ checkTupSize tup_size
patSigErr :: Outputable a => a -> SDoc
patSigErr ty
= (ptext (sLit "Illegal signature in pattern:") <+> ppr ty)
- $$ nest 4 (ptext (sLit "Use -XPatternSignatures to permit it"))
+ $$ nest 4 (ptext (sLit "Use -XScopedTypeVariables to permit it"))
dupFieldErr :: String -> RdrName -> SDoc
dupFieldErr str dup
diff --git a/compiler/rename/RnSource.lhs b/compiler/rename/RnSource.lhs
index 27de40f662..cebc6746c6 100644
--- a/compiler/rename/RnSource.lhs
+++ b/compiler/rename/RnSource.lhs
@@ -174,7 +174,9 @@ rnSrcDecls shadowP group@(HsGroup {hs_valds = val_decls,
-- (H) Rename Everything else
(rn_inst_decls, src_fvs2) <- rnList rnSrcInstDecl inst_decls ;
- (rn_rule_decls, src_fvs3) <- rnList rnHsRuleDecl rule_decls ;
+ (rn_rule_decls, src_fvs3) <- setOptM Opt_ScopedTypeVariables $
+ rnList rnHsRuleDecl rule_decls ;
+ -- Inside RULES, scoped type variables are on
(rn_foreign_decls, src_fvs4) <- rnList rnHsForeignDecl foreign_decls ;
(rn_default_decls, src_fvs5) <- rnList rnDefaultDecl default_decls ;
(rn_deriv_decls, src_fvs6) <- rnList rnSrcDerivDecl deriv_decls ;
diff --git a/compiler/simplCore/SimplUtils.lhs b/compiler/simplCore/SimplUtils.lhs
index be5c4b3e6a..1fdde7f209 100644
--- a/compiler/simplCore/SimplUtils.lhs
+++ b/compiler/simplCore/SimplUtils.lhs
@@ -797,7 +797,7 @@ activeInline env id
activeRule :: DynFlags -> SimplEnv -> Maybe (Activation -> Bool)
-- Nothing => No rules at all
activeRule dflags env
- | not (dopt Opt_RewriteRules dflags)
+ | not (dopt Opt_EnableRewriteRules dflags)
= Nothing -- Rewriting is off
| otherwise
= case getMode env of
diff --git a/compiler/typecheck/TcDeriv.lhs b/compiler/typecheck/TcDeriv.lhs
index efc46cd34f..ea38b34d04 100644
--- a/compiler/typecheck/TcDeriv.lhs
+++ b/compiler/typecheck/TcDeriv.lhs
@@ -308,8 +308,8 @@ renameDeriv is_boot gen_binds insts
| otherwise
= discardWarnings $ -- Discard warnings about unused bindings etc
- do { (rn_gen, dus_gen) <- setOptM Opt_PatternSignatures $ -- Type signatures in patterns
- -- are used in the generic binds
+ do { (rn_gen, dus_gen) <- setOptM Opt_ScopedTypeVariables $ -- Type signatures in patterns
+ -- are used in the generic binds
rnTopBinds (ValBindsIn gen_binds [])
; keepAliveSetTc (duDefs dus_gen) -- Mark these guys to be kept alive