Fix warnings on non-Windows
[ghc-hetmet.git] / compiler / main / DynFlags.hs
index 25dddeb..fb87391 100644 (file)
@@ -1,6 +1,5 @@
 
 {-# OPTIONS -fno-warn-missing-fields #-}
-{-# OPTIONS -w #-}
 -- The above warning supression flag is a temporary kludge.
 -- While working on this module you are encouraged to remove it and fix
 -- any warnings in the module. See
@@ -29,6 +28,8 @@ module DynFlags (
        GhcLink(..), isNoLink,
        PackageFlag(..),
        Option(..),
+       DynLibLoader(..),
+        fFlags, xFlags,
 
        -- Configuration of the core-to-core and stg-to-stg phases
        CoreToDo(..),
@@ -59,6 +60,8 @@ module DynFlags (
     compilerInfo,
   ) where
 
+-- XXX This define is a bit of a hack, and should be done more nicely
+#define FAST_STRING_NOT_NEEDED 1
 #include "HsVersions.h"
 
 import Module
@@ -85,13 +88,9 @@ import {-# SOURCE #-} ErrUtils ( Severity(..), Message, mkLocMessage )
 import Data.IORef      ( readIORef )
 import Control.Exception ( throwDyn )
 import Control.Monad   ( when )
-#ifdef mingw32_TARGET_OS
-import Data.List       ( isPrefixOf )
-#else
-import Util            ( split )
-#endif
 
 import Data.Char
+import System.FilePath
 import System.IO        ( hPutStrLn, stderr )
 
 -- -----------------------------------------------------------------------------
@@ -125,6 +124,7 @@ data DynFlag
    | Opt_D_dump_rn
    | Opt_D_dump_simpl
    | Opt_D_dump_simpl_iterations
+   | Opt_D_dump_simpl_phases
    | Opt_D_dump_spec
    | Opt_D_dump_prep
    | Opt_D_dump_stg
@@ -151,6 +151,7 @@ data DynFlag
    | Opt_D_dump_hi_diffs
    | Opt_D_dump_minimal_imports
    | Opt_D_dump_mod_cycles
+   | Opt_D_dump_view_pattern_commoning
    | Opt_D_faststring_stats
    | Opt_DumpToFile                    -- ^ Append dump output to files instead of stdout.
    | Opt_DoCoreLinting
@@ -192,6 +193,7 @@ data DynFlag
    | Opt_PArr                          -- Syntactic support for parallel arrays
    | Opt_Arrows                                -- Arrow-notation syntax
    | Opt_TemplateHaskell
+   | Opt_QuasiQuotes
    | Opt_ImplicitParams
    | Opt_Generics
    | Opt_ImplicitPrelude 
@@ -203,6 +205,7 @@ data DynFlag
    | Opt_DisambiguateRecordFields
    | Opt_RecordWildCards
    | Opt_RecordPuns
+   | Opt_ViewPatterns
    | Opt_GADTs
    | Opt_RelaxedPolyRec
    | Opt_StandaloneDeriving
@@ -221,12 +224,14 @@ data DynFlag
    | Opt_KindSignatures
    | Opt_PatternSignatures
    | Opt_ParallelListComp
+   | Opt_TransformListComp
    | Opt_GeneralizedNewtypeDeriving
    | Opt_RecursiveDo
    | Opt_PatternGuards
    | Opt_LiberalTypeSynonyms
    | Opt_Rank2Types
    | Opt_RankNTypes
+   | Opt_ImpredicativeTypes
    | Opt_TypeOperators
 
    | Opt_PrintExplicitForalls
@@ -241,7 +246,6 @@ data DynFlag
    | Opt_OmitInterfacePragmas
    | Opt_DoLambdaEtaExpansion
    | Opt_IgnoreAsserts
-   | Opt_IgnoreBreakpoints
    | Opt_DoEtaReduction
    | Opt_CaseMerge
    | Opt_UnboxStrictFields
@@ -265,10 +269,12 @@ data DynFlag
    | Opt_HideAllPackages
    | Opt_PrintBindResult
    | Opt_Haddock
+   | Opt_HaddockOptions
    | Opt_Hpc_No_Auto
    | Opt_BreakOnException
    | Opt_BreakOnError
    | Opt_PrintEvldWithShow
+   | Opt_PrintBindContents
    | Opt_GenManifest
    | Opt_EmbedManifest
    | Opt_RunCPSZ
@@ -293,10 +299,12 @@ data DynFlags = DynFlags {
   extCoreName          :: String,      -- name of the .core output file
   verbosity            :: Int,         -- verbosity level
   optLevel             :: Int,         -- optimisation level
+  simplPhases           :: Int,         -- number of simplifier phases
   maxSimplIterations    :: Int,                -- max simplifier iterations
   ruleCheck            :: Maybe String,
 
-  specThreshold                :: Int,         -- Threshold for function specialisation
+  specConstrThreshold   :: Maybe Int,  -- Threshold for SpecConstr
+  liberateCaseThreshold :: Maybe Int,   -- Threshold for LiberateCase 
 
   stolen_x86_regs      :: Int,         
   cmdlineHcIncludes    :: [String],    -- -#includes
@@ -323,6 +331,7 @@ data DynFlags = DynFlags {
 
   outputFile           :: Maybe String,
   outputHi             :: Maybe String,
+  dynLibLoader         :: DynLibLoader,
 
   -- | This is set by DriverPipeline.runPipeline based on where
   --   its output is going.
@@ -388,7 +397,9 @@ data DynFlags = DynFlags {
   flags                :: [DynFlag],
   
   -- message output
-  log_action            :: Severity -> SrcSpan -> PprStyle -> Message -> IO ()
+  log_action            :: Severity -> SrcSpan -> PprStyle -> Message -> IO (),
+
+  haddockOptions :: Maybe String
  }
 
 data HscTarget
@@ -427,11 +438,11 @@ data GhcLink      -- What to do in the link step, if there is one
   | LinkBinary         -- Link object code into a binary
   | LinkInMemory        -- Use the in-memory dynamic linker
   | LinkDynLib         -- Link objects into a dynamic lib (DLL on Windows, DSO on ELF platforms)
-  deriving Eq
+  deriving (Eq, Show)
 
 isNoLink :: GhcLink -> Bool
 isNoLink NoLink = True
-isNoLink other  = False
+isNoLink _      = False
 
 data PackageFlag
   = ExposePackage  String
@@ -439,14 +450,23 @@ data PackageFlag
   | IgnorePackage  String
   deriving Eq
 
+defaultHscTarget :: HscTarget
 defaultHscTarget = defaultObjectTarget
 
 -- | the 'HscTarget' value corresponding to the default way to create
 -- object files on the current platform.
+defaultObjectTarget :: HscTarget
 defaultObjectTarget
   | cGhcWithNativeCodeGen == "YES"     =  HscAsm
   | otherwise                          =  HscC
 
+data DynLibLoader
+  = Deployable
+  | Wrapped (Maybe String)
+  | SystemDependent
+  deriving Eq
+
+initDynFlags :: DynFlags -> IO DynFlags
 initDynFlags dflags = do
  -- someday these will be dynamic flags
  ways <- readIORef v_Ways
@@ -458,6 +478,7 @@ initDynFlags dflags = do
        rtsBuildTag     = rts_build_tag
        }
 
+defaultDynFlags :: DynFlags
 defaultDynFlags =
      DynFlags {
        ghcMode                 = CompManager,
@@ -469,9 +490,11 @@ defaultDynFlags =
        extCoreName             = "",
        verbosity               = 0, 
        optLevel                = 0,
+        simplPhases             = 2,
        maxSimplIterations      = 4,
        ruleCheck               = Nothing,
-       specThreshold           = 200,
+       specConstrThreshold     = Just 200,
+        liberateCaseThreshold   = Just 200,
        stolen_x86_regs         = 4,
        cmdlineHcIncludes       = [],
        importPaths             = ["."],
@@ -491,6 +514,7 @@ defaultDynFlags =
 
        outputFile              = Nothing,
        outputHi                = Nothing,
+       dynLibLoader            = Deployable,
        dumpPrefix              = Nothing,
        dumpPrefixForce         = Nothing,
        includePaths            = [],
@@ -517,27 +541,27 @@ defaultDynFlags =
        packageFlags            = [],
         pkgDatabase             = Nothing,
         pkgState                = panic "no package state yet: call GHC.setSessionDynFlags",
-       flags = [ 
-           Opt_ReadUserPackageConf,
-    
-           Opt_MonoPatBinds,   -- Experimentally, I'm making this non-standard
-                               -- behaviour the default, to see if anyone notices
-                               -- SLPJ July 06
+  haddockOptions = Nothing,
+        flags = [
+            Opt_ReadUserPackageConf,
 
-           Opt_ImplicitPrelude,
-           Opt_MonomorphismRestriction,
+            Opt_MonoPatBinds,   -- Experimentally, I'm making this non-standard
+                                -- behaviour the default, to see if anyone notices
+                                -- SLPJ July 06
+
+            Opt_ImplicitPrelude,
+            Opt_MonomorphismRestriction,
+
+            Opt_DoAsmMangling,
 
-           Opt_DoAsmMangling,
-    
             Opt_GenManifest,
             Opt_EmbedManifest,
+            Opt_PrintBindContents
+            ]
+            ++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns]
+                    -- The default -O0 options
+            ++ standardWarnings,
 
-           -- on by default:
-           Opt_PrintBindResult ]
-           ++ [f | (ns,f) <- optLevelFlags, 0 `elem` ns]
-                   -- The default -O0 options
-           ++ standardWarnings,
-               
         log_action = \severity srcSpan style msg -> 
                         case severity of
                           SevInfo  -> hPutStrLn stderr (show (msg style))
@@ -574,6 +598,14 @@ getVerbFlag dflags
   | verbosity dflags >= 3  = "-v" 
   | otherwise =  ""
 
+setObjectDir, setHiDir, setStubDir, setObjectSuf, setHiSuf, setHcSuf, parseDynLibLoaderMode,
+         setPgmP, setPgmL, setPgmF, setPgmc, setPgmm, setPgms, setPgma, setPgml, setPgmdll, setPgmwindres,
+         addOptL, addOptP, addOptF, addOptc, addOptm, addOpta, addOptl, addOptdep, addOptwindres,
+         addCmdlineFramework, addHaddockOpts
+   :: String -> DynFlags -> DynFlags
+setOutputFile, setOutputHi, setDumpPrefixForce
+   :: Maybe String -> DynFlags -> DynFlags
+
 setObjectDir  f d = d{ objectDir  = Just f}
 setHiDir      f d = d{ hiDir      = Just f}
 setStubDir    f d = d{ stubDir    = Just f, includePaths = f : includePaths d }
@@ -587,6 +619,15 @@ setHcSuf      f d = d{ hcSuf      = f}
 setOutputFile f d = d{ outputFile = f}
 setOutputHi   f d = d{ outputHi   = f}
 
+parseDynLibLoaderMode f d =
+ case splitAt 8 f of
+   ("deploy", "")       -> d{ dynLibLoader = Deployable }
+   ("sysdep", "")       -> d{ dynLibLoader = SystemDependent }
+   ("wrapped", "")      -> d{ dynLibLoader = Wrapped Nothing }
+   ("wrapped:", "hard") -> d{ dynLibLoader = Wrapped Nothing }
+   ("wrapped:", flex)   -> d{ dynLibLoader = Wrapped (Just flex) }
+   (_,_)                -> error "Unknown dynlib loader"
+
 setDumpPrefixForce f d = d { dumpPrefixForce = f}
 
 -- XXX HACK: Prelude> words "'does not' work" ===> ["'does","not'","work"]
@@ -615,6 +656,8 @@ addOptwindres f d = d{ opt_windres = f : opt_windres d}
 
 addCmdlineFramework f d = d{ cmdlineFrameworks = f : cmdlineFrameworks d}
 
+addHaddockOpts f d = d{ haddockOptions = Just f}
+
 -- -----------------------------------------------------------------------------
 -- Command-line options
 
@@ -674,6 +717,7 @@ optLevelFlags
 -- -----------------------------------------------------------------------------
 -- Standard sets of warning options
 
+standardWarnings :: [DynFlag]
 standardWarnings
     = [ Opt_WarnDeprecations,
        Opt_WarnOverlappingPatterns,
@@ -682,6 +726,7 @@ standardWarnings
        Opt_WarnDuplicateExports
       ]
 
+minusWOpts :: [DynFlag]
 minusWOpts
     = standardWarnings ++ 
       [        Opt_WarnUnusedBinds,
@@ -691,6 +736,7 @@ minusWOpts
        Opt_WarnDodgyImports
       ]
 
+minusWallOpts :: [DynFlag]
 minusWallOpts
     = minusWOpts ++
       [        Opt_WarnTypeDefaults,
@@ -701,6 +747,7 @@ minusWallOpts
       ]
 
 -- minuswRemovesOpts should be every warning option
+minuswRemovesOpts :: [DynFlag]
 minuswRemovesOpts
     = minusWallOpts ++
       [Opt_WarnImplicitPrelude,
@@ -757,7 +804,11 @@ data FloatOutSwitches
 -- The core-to-core pass ordering is derived from the DynFlags:
 runWhen :: Bool -> CoreToDo -> CoreToDo
 runWhen True  do_this = do_this
-runWhen False do_this = CoreDoNothing
+runWhen False _       = CoreDoNothing
+
+runMaybe :: Maybe a -> (a -> CoreToDo) -> CoreToDo
+runMaybe (Just x) f = f x
+runMaybe Nothing  _ = CoreDoNothing
 
 getCoreToDo :: DynFlags -> [CoreToDo]
 getCoreToDo dflags
@@ -765,6 +816,7 @@ getCoreToDo dflags
   | otherwise = core_todo
   where
     opt_level            = optLevel dflags
+    phases        = simplPhases dflags
     max_iter             = maxSimplIterations dflags
     strictness    = dopt Opt_Strictness dflags
     full_laziness = dopt Opt_FullLaziness dflags
@@ -774,17 +826,32 @@ getCoreToDo dflags
     rule_check    = ruleCheck dflags
     vectorisation = dopt Opt_Vectorise dflags
 
-    core_todo = 
-     if opt_level == 0 then
-      [
-       CoreDoSimplify (SimplPhase 0) [
-           MaxSimplifierIterations max_iter
-       ]
-      ]
-     else {- opt_level >= 1 -} [ 
+    maybe_rule_check phase = runMaybe rule_check (CoreDoRuleCheck phase)
+
+    simpl_phase phase iter = CoreDoPasses
+                               [ CoreDoSimplify (SimplPhase phase) [
+                                   MaxSimplifierIterations iter
+                                 ],
+                                 maybe_rule_check phase
+                               ]
+
+                -- By default, we have 2 phases before phase 0.
+
+               -- Want to run with inline phase 2 after the specialiser to give
+               -- maximum chance for fusion to work before we inline build/augment
+               -- in phase 1.  This made a difference in 'ansi' where an 
+               -- overloaded function wasn't inlined till too late.
+
+               -- Need phase 1 so that build/augment get 
+               -- inlined.  I found that spectral/hartel/genfft lost some useful
+               -- strictness in the function sumcode' if augment is not inlined
+               -- before strictness analysis runs
+    simpl_phases = CoreDoPasses [ simpl_phase phase max_iter
+                                  | phase <- [phases, phases-1 .. 1] ]
+
 
        -- initial simplify: mk specialiser happy: minimum effort please
-       CoreDoSimplify SimplGently [
+    simpl_gently = CoreDoSimplify SimplGently [
                        --      Simplify "gently"
                        -- Don't inline anything till full laziness has bitten
                        -- In particular, inlining wrappers inhibits floating
@@ -798,16 +865,19 @@ getCoreToDo dflags
             NoCaseOfCase,      -- Don't do case-of-case transformations.
                                -- This makes full laziness work better
            MaxSimplifierIterations max_iter
-       ],
+       ]
+
+    core_todo = 
+     if opt_level == 0 then
+       [simpl_phase 0 max_iter]
+     else {- opt_level >= 1 -} [ 
 
+       -- initial simplify: mk specialiser happy: minimum effort please
+        simpl_gently,
 
         -- We run vectorisation here for now, but we might also try to run
         -- it later
-        runWhen vectorisation (CoreDoPasses [
-                  CoreDoVectorisation,
-                  CoreDoSimplify SimplGently
-                                  [NoCaseOfCase,
-                                   MaxSimplifierIterations max_iter]]),
+        runWhen vectorisation (CoreDoPasses [ CoreDoVectorisation, simpl_gently ]),
 
        -- Specialisation is best done before full laziness
        -- so that overloaded functions have all their dictionary lambdas manifest
@@ -817,29 +887,11 @@ getCoreToDo dflags
 
        CoreDoFloatInwards,
 
-       CoreDoSimplify (SimplPhase 2) [
-               -- Want to run with inline phase 2 after the specialiser to give
-               -- maximum chance for fusion to work before we inline build/augment
-               -- in phase 1.  This made a difference in 'ansi' where an 
-               -- overloaded function wasn't inlined till too late.
-          MaxSimplifierIterations max_iter
-       ],
-       case rule_check of { Just pat -> CoreDoRuleCheck 2 pat; Nothing -> CoreDoNothing },
+        simpl_phases,
 
-       CoreDoSimplify (SimplPhase 1) [
-               -- Need inline-phase2 here so that build/augment get 
-               -- inlined.  I found that spectral/hartel/genfft lost some useful
-               -- strictness in the function sumcode' if augment is not inlined
-               -- before strictness analysis runs
-          MaxSimplifierIterations max_iter
-       ],
-       case rule_check of { Just pat -> CoreDoRuleCheck 1 pat; Nothing -> CoreDoNothing },
-
-       CoreDoSimplify (SimplPhase 0) [
                -- Phase 0: allow all Ids to be inlined now
                -- This gets foldr inlined before strictness analysis
 
-          MaxSimplifierIterations 3
                -- At least 3 iterations because otherwise we land up with
                -- huge dead expressions because of an infelicity in the 
                -- simpifier.   
@@ -847,9 +899,8 @@ getCoreToDo dflags
                -- ==>  let k = BIG in letrec go = \xs -> ...(k x).... in go xs
                -- ==>  let k = BIG in letrec go = \xs -> ...(BIG x).... in go xs
                -- Don't stop now!
+       simpl_phase 0 (max max_iter 3),
 
-       ],
-       case rule_check of { Just pat -> CoreDoRuleCheck 0 pat; Nothing -> CoreDoNothing },
 
 #ifdef OLD_STRICTNESS
        CoreDoOldStrictness,
@@ -858,9 +909,8 @@ getCoreToDo dflags
                CoreDoStrictness,
                CoreDoWorkerWrapper,
                CoreDoGlomBinds,
-               CoreDoSimplify (SimplPhase 0) [
-                  MaxSimplifierIterations max_iter
-               ]]),
+                simpl_phase 0 max_iter
+                ]),
 
        runWhen full_laziness 
          (CoreDoFloatOutwards (FloatOutSw False    -- Not lambdas
@@ -879,24 +929,23 @@ getCoreToDo dflags
 
        CoreDoFloatInwards,
 
-       case rule_check of { Just pat -> CoreDoRuleCheck 0 pat; Nothing -> CoreDoNothing },
+       maybe_rule_check 0,
 
                -- Case-liberation for -O2.  This should be after
                -- strictness analysis and the simplification which follows it.
        runWhen liberate_case (CoreDoPasses [
            CoreLiberateCase,
-           CoreDoSimplify (SimplPhase 0) [
-                 MaxSimplifierIterations max_iter
-           ] ]),       -- Run the simplifier after LiberateCase to vastly 
+            simpl_phase 0 max_iter
+            ]),         -- Run the simplifier after LiberateCase to vastly 
                        -- reduce the possiblility of shadowing
                        -- Reason: see Note [Shadowing] in SpecConstr.lhs
 
        runWhen spec_constr CoreDoSpecConstr,
 
+        maybe_rule_check 0,
+
        -- Final clean-up simplification:
-       CoreDoSimplify (SimplPhase 0) [
-         MaxSimplifierIterations max_iter
-       ]
+        simpl_phase 0 max_iter
      ]
 
 -- -----------------------------------------------------------------------------
@@ -929,10 +978,13 @@ allFlags :: [String]
 allFlags = map ('-':) $
            [ name | (name, optkind) <- dynamic_flags, ok optkind ] ++
            map ("fno-"++) flags ++
-           map ("f"++) flags
+           map ("f"++) flags ++
+           map ("X"++) xs ++
+           map ("XNo"++) xs
     where ok (PrefixPred _ _) = False
           ok _ = True
           flags = map fst fFlags
+          xs = map fst xFlags
 
 dynamic_flags :: [(String, OptKind DynP)]
 dynamic_flags = [
@@ -972,6 +1024,7 @@ dynamic_flags = [
   ,  ( "c"             , NoArg (upd $ \d -> d{ ghcLink=NoLink } ))
   ,  ( "no-link"       , NoArg (upd $ \d -> d{ ghcLink=NoLink } )) -- Dep.
   ,  ( "shared"                , NoArg (upd $ \d -> d{ ghcLink=LinkDynLib } ))
+  ,  ( "dynload"       , HasArg (upd . parseDynLibLoaderMode))
 
        ------- Libraries ---------------------------------------------------
   ,  ( "L"             , Prefix addLibraryPath )
@@ -1009,6 +1062,7 @@ dynamic_flags = [
   ,  ( "no-hs-main"     , NoArg (setDynFlag Opt_NoHsMain))
   ,  ( "main-is"       , SepArg setMainIs )
   ,  ( "haddock"       , NoArg (setDynFlag Opt_Haddock) )
+  ,  ( "haddock-opts"   , HasArg (upd . addHaddockOpts))
   ,  ( "hpcdir"                , SepArg setOptHpcDir )
 
        ------- recompilation checker (DEPRECATED, use -fforce-recomp) -----
@@ -1062,6 +1116,7 @@ dynamic_flags = [
   ,  ( "ddump-rn",              setDumpFlag Opt_D_dump_rn)
   ,  ( "ddump-simpl",           setDumpFlag Opt_D_dump_simpl)
   ,  ( "ddump-simpl-iterations", setDumpFlag Opt_D_dump_simpl_iterations)
+  ,  ( "ddump-simpl-phases",     setDumpFlag Opt_D_dump_simpl_phases)
   ,  ( "ddump-spec",            setDumpFlag Opt_D_dump_spec)
   ,  ( "ddump-prep",            setDumpFlag Opt_D_dump_prep)
   ,  ( "ddump-stg",             setDumpFlag Opt_D_dump_stg)
@@ -1087,6 +1142,7 @@ dynamic_flags = [
   ,  ( "ddump-vect",            setDumpFlag Opt_D_dump_vect)
   ,  ( "ddump-hpc",             setDumpFlag Opt_D_dump_hpc)
   ,  ( "ddump-mod-cycles",              setDumpFlag Opt_D_dump_mod_cycles)
+  ,  ( "ddump-view-pattern-commoning", setDumpFlag Opt_D_dump_view_pattern_commoning)
   ,  ( "ddump-to-file",          setDumpFlag Opt_DumpToFile)
   ,  ( "ddump-hi-diffs",         NoArg (setDynFlag Opt_D_dump_hi_diffs))
   ,  ( "dcore-lint",            NoArg (setDynFlag Opt_DoCoreLinting))
@@ -1117,14 +1173,21 @@ dynamic_flags = [
   ,  ( "O"     , OptIntSuffix (\mb_n -> upd (setOptLevel (mb_n `orElse` 1))))
                -- If the number is missing, use 1
 
+  ,  ( "fsimplifier-phases",         IntSuffix (\n ->
+                upd (\dfs -> dfs{ simplPhases = n })) )
   ,  ( "fmax-simplifier-iterations", IntSuffix (\n -> 
                upd (\dfs -> dfs{ maxSimplIterations = n })) )
 
-       -- liberate-case-threshold is an old flag for '-fspec-threshold'
-  ,  ( "fspec-threshold",          IntSuffix (\n -> upd (\dfs -> dfs{ specThreshold = n })))
-  ,  ( "fliberate-case-threshold", IntSuffix (\n -> upd (\dfs -> dfs{ specThreshold = n })))
+  ,  ( "fspec-constr-threshold",      IntSuffix (\n ->
+                upd (\dfs -> dfs{ specConstrThreshold = Just n })))
+  ,  ( "fno-spec-constr-threshold",   NoArg (
+                upd (\dfs -> dfs{ specConstrThreshold = Nothing })))
+  ,  ( "fliberate-case-threshold",    IntSuffix (\n ->
+                upd (\dfs -> dfs{ liberateCaseThreshold = Just n })))
+  ,  ( "fno-liberate-case-threshold", NoArg (
+                upd (\dfs -> dfs{ liberateCaseThreshold = Nothing })))
 
-  ,  ( "frule-check", SepArg (\s -> upd (\dfs -> dfs{ ruleCheck = Just s })))
+  ,  ( "frule-check",     SepArg (\s -> upd (\dfs -> dfs{ ruleCheck = Just s })))
   ,  ( "fcontext-stack"        , IntSuffix $ \n -> upd $ \dfs -> dfs{ ctxtStkDepth = n })
 
         ------ Compiler flags -----------------------------------------------
@@ -1155,6 +1218,7 @@ dynamic_flags = [
 
 -- these -f<blah> flags can all be reversed with -fno-<blah>
 
+fFlags :: [(String, DynFlag)]
 fFlags = [
   ( "warn-dodgy-imports",               Opt_WarnDodgyImports ),
   ( "warn-duplicate-exports",           Opt_WarnDuplicateExports ),
@@ -1186,7 +1250,6 @@ fFlags = [
   ( "omit-interface-pragmas",           Opt_OmitInterfacePragmas ),
   ( "do-lambda-eta-expansion",          Opt_DoLambdaEtaExpansion ),
   ( "ignore-asserts",                   Opt_IgnoreAsserts ),
-  ( "ignore-breakpoints",               Opt_IgnoreBreakpoints),
   ( "do-eta-reduction",                 Opt_DoEtaReduction ),
   ( "case-merge",                       Opt_CaseMerge ),
   ( "unbox-strict-fields",              Opt_UnboxStrictFields ),
@@ -1200,6 +1263,7 @@ fFlags = [
   ( "break-on-exception",               Opt_BreakOnException ),
   ( "break-on-error",                   Opt_BreakOnError ),
   ( "print-evld-with-show",             Opt_PrintEvldWithShow ),
+  ( "print-bind-contents",              Opt_PrintBindContents ),
   ( "run-cps",                          Opt_RunCPSZ ),
   ( "convert-to-zipper-and-back",       Opt_ConvertToZipCfgAndBack),
   ( "vectorise",                        Opt_Vectorise ),
@@ -1257,16 +1321,19 @@ xFlags = [
   ( "PatternSignatures",                Opt_PatternSignatures ),
   ( "EmptyDataDecls",                   Opt_EmptyDataDecls ),
   ( "ParallelListComp",                 Opt_ParallelListComp ),
+  ( "TransformListComp",                Opt_TransformListComp ),
   ( "ForeignFunctionInterface",         Opt_ForeignFunctionInterface ),
   ( "UnliftedFFITypes",                 Opt_UnliftedFFITypes ),
   ( "LiberalTypeSynonyms",             Opt_LiberalTypeSynonyms ),
   ( "Rank2Types",                       Opt_Rank2Types ),
   ( "RankNTypes",                       Opt_RankNTypes ),
+  ( "ImpredicativeTypes",              Opt_ImpredicativeTypes ),
   ( "TypeOperators",                    Opt_TypeOperators ),
   ( "RecursiveDo",                      Opt_RecursiveDo ),
   ( "Arrows",                           Opt_Arrows ),
   ( "PArr",                             Opt_PArr ),
   ( "TemplateHaskell",                  Opt_TemplateHaskell ),
+  ( "QuasiQuotes",                      Opt_QuasiQuotes ),
   ( "Generics",                         Opt_Generics ),
   -- On by default:
   ( "ImplicitPrelude",                  Opt_ImplicitPrelude ),
@@ -1275,6 +1342,7 @@ xFlags = [
   ( "DisambiguateRecordFields",         Opt_DisambiguateRecordFields ),
   ( "OverloadedStrings",                Opt_OverloadedStrings ),
   ( "GADTs",                            Opt_GADTs ),
+  ( "ViewPatterns",                     Opt_ViewPatterns),
   ( "TypeFamilies",                     Opt_TypeFamilies ),
   ( "BangPatterns",                     Opt_BangPatterns ),
   -- On by default:
@@ -1302,16 +1370,20 @@ xFlags = [
 
 impliedFlags :: [(DynFlag, [DynFlag])]
 impliedFlags = [
-  ( Opt_GADTs, [Opt_RelaxedPolyRec] )  -- We want type-sig variables to be completely rigid for GADTs
+   ( Opt_GADTs,              [Opt_RelaxedPolyRec] )    -- We want type-sig variables to 
+                                                       --      be completely rigid for GADTs
+ , ( Opt_ScopedTypeVariables, [Opt_RelaxedPolyRec] )   -- Ditto for scoped type variables; see
+                                                       --      Note [Scoped tyvars] in TcBinds
   ]
 
+glasgowExtsFlags :: [DynFlag]
 glasgowExtsFlags = [
              Opt_PrintExplicitForalls
            , Opt_ForeignFunctionInterface
            , Opt_UnliftedFFITypes
-                  , Opt_GADTs
-                  , Opt_ImplicitParams 
-                  , Opt_ScopedTypeVariables
+          , Opt_GADTs
+          , Opt_ImplicitParams 
+          , Opt_ScopedTypeVariables
            , Opt_UnboxedTuples
            , Opt_TypeSynonymInstances
            , Opt_StandaloneDeriving
@@ -1321,13 +1393,14 @@ glasgowExtsFlags = [
            , Opt_ConstrainedClassMethods
            , Opt_MultiParamTypeClasses
            , Opt_FunctionalDependencies
-                  , Opt_MagicHash
+          , Opt_MagicHash
            , Opt_PolymorphicComponents
            , Opt_ExistentialQuantification
            , Opt_UnicodeSyntax
            , Opt_PatternGuards
            , Opt_LiberalTypeSynonyms
            , Opt_RankNTypes
+           , Opt_ImpredicativeTypes
            , Opt_TypeOperators
            , Opt_RecursiveDo
            , Opt_ParallelListComp
@@ -1335,7 +1408,7 @@ glasgowExtsFlags = [
            , Opt_KindSignatures
            , Opt_PatternSignatures
            , Opt_GeneralizedNewtypeDeriving
-                  , Opt_TypeFamilies ]
+          , Opt_TypeFamilies ]
 
 ------------------
 isFlag :: [(String,a)] -> String -> Bool
@@ -1349,7 +1422,7 @@ isPrefFlag pref flags no_f
 ------------------
 getFlag :: [(String,a)] -> String -> a
 getFlag flags f = case [ opt | (ff, opt) <- flags, ff == f] of
-                      (o:os) -> o
+                      (o:_)  -> o
                       []     -> panic ("get_flag " ++ f)
 
 getPrefFlag :: String -> [(String,a)] -> String -> a
@@ -1396,10 +1469,13 @@ setDumpFlag dump_flag
 setVerbosity :: Maybe Int -> DynP ()
 setVerbosity mb_n = upd (\dfs -> dfs{ verbosity = mb_n `orElse` 3 })
 
+addCmdlineHCInclude :: String -> DynP ()
 addCmdlineHCInclude a = upd (\s -> s{cmdlineHcIncludes =  a : cmdlineHcIncludes s})
 
+extraPkgConf_ :: FilePath -> DynP ()
 extraPkgConf_  p = upd (\s -> s{ extraPkgConfs = p : extraPkgConfs s })
 
+exposePackage, hidePackage, ignorePackage :: String -> DynP ()
 exposePackage p = 
   upd (\s -> s{ packageFlags = ExposePackage p : packageFlags s })
 hidePackage p = 
@@ -1407,6 +1483,7 @@ hidePackage p =
 ignorePackage p = 
   upd (\s -> s{ packageFlags = IgnorePackage p : packageFlags s })
 
+setPackageName :: String -> DynFlags -> DynFlags
 setPackageName p
   | Nothing <- unpackPackageId pid
   = throwDyn (CmdLineError ("cannot parse \'" ++ p ++ "\' as a package identifier"))
@@ -1417,6 +1494,7 @@ setPackageName p
 
 -- If we're linking a binary, then only targets that produce object
 -- code are allowed (requests for other target types are ignored).
+setTarget :: HscTarget -> DynP ()
 setTarget l = upd set
   where 
    set dfs 
@@ -1427,6 +1505,7 @@ setTarget l = upd set
 -- used by -fasm and -fvia-C, which switch from one to the other, but
 -- not from bytecode to object-code.  The idea is that -fasm/-fvia-C
 -- can be safely used in an OPTIONS_GHC pragma.
+setObjTarget :: HscTarget -> DynP ()
 setObjTarget l = upd set
   where 
    set dfs 
@@ -1461,6 +1540,8 @@ setMainIs arg
 -----------------------------------------------------------------------------
 -- Paths & Libraries
 
+addImportPath, addLibraryPath, addIncludePath, addFrameworkPath :: FilePath -> DynP ()
+
 -- -i on its own deletes the import paths
 addImportPath "" = upd (\s -> s{importPaths = []})
 addImportPath p  = upd (\s -> s{importPaths = importPaths s ++ splitPathList p})
@@ -1475,7 +1556,10 @@ addIncludePath p =
 addFrameworkPath p = 
   upd (\s -> s{frameworkPaths = frameworkPaths s ++ splitPathList p})
 
+#ifndef mingw32_TARGET_OS
+split_marker :: Char
 split_marker = ':'   -- not configurable (ToDo)
+#endif
 
 splitPathList :: String -> [String]
 splitPathList s = filter notNull (splitUp s)
@@ -1519,7 +1603,7 @@ splitPathList s = filter notNull (splitUp s)
     -- finding the next split marker.
     findNextPath xs = 
         case break (`elem` split_markers) xs of
-          (p, d:ds) -> (p, ds)
+           (p, _:ds) -> (p, ds)
           (p, xs)   -> (p, xs)
 
     split_markers :: [Char]
@@ -1536,32 +1620,28 @@ setTmpDir :: FilePath -> DynFlags -> DynFlags
 setTmpDir dir dflags = dflags{ tmpDir = canonicalise dir }
   where
 #if !defined(mingw32_HOST_OS)
-     canonicalise p = normalisePath p
+     canonicalise p = normalise p
 #else
-       -- Canonicalisation of temp path under win32 is a bit more
-       -- involved: (a) strip trailing slash, 
-       --           (b) normalise slashes
-       --           (c) just in case, if there is a prefix /cygdrive/x/, change to x:
-       -- 
-     canonicalise path = normalisePath (xltCygdrive (removeTrailingSlash path))
-
-        -- if we're operating under cygwin, and TMP/TEMP is of
-       -- the form "/cygdrive/drive/path", translate this to
-       -- "drive:/path" (as GHC isn't a cygwin app and doesn't
-       -- understand /cygdrive paths.)
-     xltCygdrive path
-      | "/cygdrive/" `isPrefixOf` path = 
-         case drop (length "/cygdrive/") path of
-           drive:xs@('/':_) -> drive:':':xs
-           _ -> path
-      | otherwise = path
-
-        -- strip the trailing backslash (awful, but we only do this once).
-     removeTrailingSlash path = 
-       case last path of
-         '/'  -> init path
-         '\\' -> init path
-         _    -> path
+     -- Canonicalisation of temp path under win32 is a bit more
+     -- involved: (a) strip trailing slash,
+     --      (b) normalise slashes
+     --     (c) just in case, if there is a prefix /cygdrive/x/, change to x:
+     canonicalise path = removeTrailingSlash $ normalise $ xltCygdrive path
+
+     -- if we're operating under cygwin, and TMP/TEMP is of
+     -- the form "/cygdrive/drive/path", translate this to
+     -- "drive:/path" (as GHC isn't a cygwin app and doesn't
+     -- understand /cygdrive paths.)
+     cygdrivePrefix = [pathSeparator] ++ "/cygdrive/" ++ [pathSeparator]
+     xltCygdrive path = case maybePrefixMatch cygdrivePrefix path of
+                        Just (drive:sep:xs)
+                         | isPathSeparator sep -> drive:':':pathSeparator:xs
+                        _ -> path
+
+     -- strip the trailing backslash (awful, but we only do this once).
+     removeTrailingSlash path
+      | isPathSeparator (last path) = init path
+      | otherwise                   = path
 #endif
 
 -----------------------------------------------------------------------------
@@ -1587,7 +1667,7 @@ setOptHpcDir arg  = upd $ \ d -> d{hpcDir = arg}
 
 machdepCCOpts :: DynFlags -> ([String], -- flags for all C compilations
                              [String]) -- for registerised HC compilations
-machdepCCOpts dflags
+machdepCCOpts _dflags
 #if alpha_TARGET_ARCH
        =       ( ["-w", "-mieee"
 #ifdef HAVE_THREADED_RTS_SUPPORT
@@ -1620,7 +1700,7 @@ machdepCCOpts dflags
       --
       -- -fomit-frame-pointer : *must* in .hc files; because we're stealing
       --   the fp (%ebp) for our register maps.
-       =  let n_regs = stolen_x86_regs dflags
+       =  let n_regs = stolen_x86_regs _dflags
               sta = opt_Static
           in
                    ( [ if sta then "-DDONT_WANT_WIN32_DLL_SUPPORT" else ""
@@ -1668,7 +1748,7 @@ machdepCCOpts dflags
 #endif
 
 picCCOpts :: DynFlags -> [String]
-picCCOpts dflags
+picCCOpts _dflags
 #if darwin_TARGET_OS
       -- Apple prefers to do things the other way round.
       -- PIC is on by default.