Merge remote branch 'origin/master' into monad-comp
authorSimon Peyton Jones <simonpj@microsoft.com>
Thu, 28 Apr 2011 10:50:15 +0000 (11:50 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Thu, 28 Apr 2011 10:50:15 +0000 (11:50 +0100)
Conflicts:
compiler/main/HscMain.lhs

1  2 
compiler/main/DynFlags.hs
compiler/main/HscMain.lhs
compiler/parser/Lexer.x
compiler/typecheck/TcRnTypes.lhs
docs/users_guide/flags.xml

@@@ -1,6 -1,3 +1,3 @@@
- {-# OPTIONS_GHC -w #-}
- -- Temporary, until rtsIsProfiled is fixed
  -- |
  -- Dynamic flags
  --
@@@ -35,8 -32,17 +32,17 @@@ module DynFlags 
          DPHBackend(..), dphPackageMaybe,
          wayNames,
  
+         Settings(..),
+         ghcUsagePath, ghciUsagePath, topDir, tmpDir, rawSettings,
+         extraGccViaCFlags, systemPackageConfig,
+         pgm_L, pgm_P, pgm_F, pgm_c, pgm_s, pgm_a, pgm_l, pgm_dll, pgm_T,
+         pgm_sysman, pgm_windres, pgm_lo, pgm_lc,
+         opt_L, opt_P, opt_F, opt_c, opt_m, opt_a, opt_l,
+         opt_windres, opt_lo, opt_lc,
          -- ** Manipulating DynFlags
-         defaultDynFlags,                -- DynFlags
+         defaultDynFlags,                -- Settings -> DynFlags
          initDynFlags,                   -- DynFlags -> IO DynFlags
  
          getOpts,                        -- DynFlags -> (DynFlags -> [a]) -> [a]
@@@ -61,7 -67,6 +67,6 @@@
          getStgToDo,
  
          -- * Compiler configuration suitable for display to the user
-         Printable(..),
          compilerInfo
  #ifdef GHCI
  -- Only in stage 2 can we be sure that the RTS 
@@@ -90,10 -95,14 +95,14 @@@ import Maybes           ( orElse 
  import SrcLoc
  import FastString
  import Outputable
+ #ifdef GHCI
  import Foreign.C      ( CInt )
+ #endif
  import {-# SOURCE #-} ErrUtils ( Severity(..), Message, mkLocMessage )
  
+ #ifdef GHCI
  import System.IO.Unsafe       ( unsafePerformIO )
+ #endif
  import Data.IORef
  import Control.Monad    ( when )
  
@@@ -101,7 -110,7 +110,7 @@@ import Data.Cha
  import Data.List
  import Data.Map (Map)
  import qualified Data.Map as Map
- import Data.Maybe
+ -- import Data.Maybe
  import System.FilePath
  import System.IO        ( stderr, hPutChar )
  
@@@ -351,7 -360,6 +360,7 @@@ data ExtensionFla
     | Opt_KindSignatures
     | Opt_ParallelListComp
     | Opt_TransformListComp
 +   | Opt_MonadComprehensions
     | Opt_GeneralizedNewtypeDeriving
     | Opt_RecursiveDo
     | Opt_DoRec
@@@ -441,41 -449,13 +450,13 @@@ data DynFlags = DynFlags 
    libraryPaths          :: [String],
    frameworkPaths        :: [String],    -- used on darwin only
    cmdlineFrameworks     :: [String],    -- ditto
-   tmpDir                :: String,      -- no trailing '/'
  
-   ghcUsagePath          :: FilePath,    -- Filled in by SysTools
-   ghciUsagePath         :: FilePath,    -- ditto
    rtsOpts               :: Maybe String,
    rtsOptsEnabled        :: RtsOptsEnabled,
  
    hpcDir                :: String,      -- ^ Path to store the .mix files
  
-   -- options for particular phases
-   opt_L                 :: [String],
-   opt_P                 :: [String],
-   opt_F                 :: [String],
-   opt_c                 :: [String],
-   opt_m                 :: [String],
-   opt_a                 :: [String],
-   opt_l                 :: [String],
-   opt_windres           :: [String],
-   opt_lo                :: [String], -- LLVM: llvm optimiser
-   opt_lc                :: [String], -- LLVM: llc static compiler
-   -- commands for particular phases
-   pgm_L                 :: String,
-   pgm_P                 :: (String,[Option]),
-   pgm_F                 :: String,
-   pgm_c                 :: (String,[Option]),
-   pgm_s                 :: (String,[Option]),
-   pgm_a                 :: (String,[Option]),
-   pgm_l                 :: (String,[Option]),
-   pgm_dll               :: (String,[Option]),
-   pgm_T                 :: String,
-   pgm_sysman            :: String,
-   pgm_windres           :: String,
-   pgm_lo                :: (String,[Option]), -- LLVM: opt llvm optimiser
-   pgm_lc                :: (String,[Option]), -- LLVM: llc static compiler
+   settings              :: Settings,
  
    --  For ghc -M
    depMakefile           :: FilePath,
  
    --  Package flags
    extraPkgConfs         :: [FilePath],
-   topDir                :: FilePath,    -- filled in by SysTools
-   systemPackageConfig   :: FilePath,    -- ditto
          -- ^ The @-package-conf@ flags given on the command line, in the order
          -- they appeared.
  
    haddockOptions :: Maybe String
   }
  
+ data Settings = Settings {
+   sGhcUsagePath          :: FilePath,    -- Filled in by SysTools
+   sGhciUsagePath         :: FilePath,    -- ditto
+   sTopDir                :: FilePath,
+   sTmpDir                :: String,      -- no trailing '/'
+   -- You shouldn't need to look things up in rawSettings directly.
+   -- They should have their own fields instead.
+   sRawSettings           :: [(String, String)],
+   sExtraGccViaCFlags     :: [String],
+   sSystemPackageConfig   :: FilePath,
+   -- commands for particular phases
+   sPgm_L                 :: String,
+   sPgm_P                 :: (String,[Option]),
+   sPgm_F                 :: String,
+   sPgm_c                 :: (String,[Option]),
+   sPgm_s                 :: (String,[Option]),
+   sPgm_a                 :: (String,[Option]),
+   sPgm_l                 :: (String,[Option]),
+   sPgm_dll               :: (String,[Option]),
+   sPgm_T                 :: String,
+   sPgm_sysman            :: String,
+   sPgm_windres           :: String,
+   sPgm_lo                :: (String,[Option]), -- LLVM: opt llvm optimiser
+   sPgm_lc                :: (String,[Option]), -- LLVM: llc static compiler
+   -- options for particular phases
+   sOpt_L                 :: [String],
+   sOpt_P                 :: [String],
+   sOpt_F                 :: [String],
+   sOpt_c                 :: [String],
+   sOpt_m                 :: [String],
+   sOpt_a                 :: [String],
+   sOpt_l                 :: [String],
+   sOpt_windres           :: [String],
+   sOpt_lo                :: [String], -- LLVM: llvm optimiser
+   sOpt_lc                :: [String]  -- LLVM: llc static compiler
+  }
+ ghcUsagePath          :: DynFlags -> FilePath
+ ghcUsagePath dflags = sGhcUsagePath (settings dflags)
+ ghciUsagePath         :: DynFlags -> FilePath
+ ghciUsagePath dflags = sGhciUsagePath (settings dflags)
+ topDir                :: DynFlags -> FilePath
+ topDir dflags = sTopDir (settings dflags)
+ tmpDir                :: DynFlags -> String
+ tmpDir dflags = sTmpDir (settings dflags)
+ rawSettings           :: DynFlags -> [(String, String)]
+ rawSettings dflags = sRawSettings (settings dflags)
+ extraGccViaCFlags     :: DynFlags -> [String]
+ extraGccViaCFlags dflags = sExtraGccViaCFlags (settings dflags)
+ systemPackageConfig   :: DynFlags -> FilePath
+ systemPackageConfig dflags = sSystemPackageConfig (settings dflags)
+ pgm_L                 :: DynFlags -> String
+ pgm_L dflags = sPgm_L (settings dflags)
+ pgm_P                 :: DynFlags -> (String,[Option])
+ pgm_P dflags = sPgm_P (settings dflags)
+ pgm_F                 :: DynFlags -> String
+ pgm_F dflags = sPgm_F (settings dflags)
+ pgm_c                 :: DynFlags -> (String,[Option])
+ pgm_c dflags = sPgm_c (settings dflags)
+ pgm_s                 :: DynFlags -> (String,[Option])
+ pgm_s dflags = sPgm_s (settings dflags)
+ pgm_a                 :: DynFlags -> (String,[Option])
+ pgm_a dflags = sPgm_a (settings dflags)
+ pgm_l                 :: DynFlags -> (String,[Option])
+ pgm_l dflags = sPgm_l (settings dflags)
+ pgm_dll               :: DynFlags -> (String,[Option])
+ pgm_dll dflags = sPgm_dll (settings dflags)
+ pgm_T                 :: DynFlags -> String
+ pgm_T dflags = sPgm_T (settings dflags)
+ pgm_sysman            :: DynFlags -> String
+ pgm_sysman dflags = sPgm_sysman (settings dflags)
+ pgm_windres           :: DynFlags -> String
+ pgm_windres dflags = sPgm_windres (settings dflags)
+ pgm_lo                :: DynFlags -> (String,[Option])
+ pgm_lo dflags = sPgm_lo (settings dflags)
+ pgm_lc                :: DynFlags -> (String,[Option])
+ pgm_lc dflags = sPgm_lc (settings dflags)
+ opt_L                 :: DynFlags -> [String]
+ opt_L dflags = sOpt_L (settings dflags)
+ opt_P                 :: DynFlags -> [String]
+ opt_P dflags = sOpt_P (settings dflags)
+ opt_F                 :: DynFlags -> [String]
+ opt_F dflags = sOpt_F (settings dflags)
+ opt_c                 :: DynFlags -> [String]
+ opt_c dflags = sOpt_c (settings dflags)
+ opt_m                 :: DynFlags -> [String]
+ opt_m dflags = sOpt_m (settings dflags)
+ opt_a                 :: DynFlags -> [String]
+ opt_a dflags = sOpt_a (settings dflags)
+ opt_l                 :: DynFlags -> [String]
+ opt_l dflags = sOpt_l (settings dflags)
+ opt_windres           :: DynFlags -> [String]
+ opt_windres dflags = sOpt_windres (settings dflags)
+ opt_lo                :: DynFlags -> [String]
+ opt_lo dflags = sOpt_lo (settings dflags)
+ opt_lc                :: DynFlags -> [String]
+ opt_lc dflags = sOpt_lc (settings dflags)
  wayNames :: DynFlags -> [WayName]
  wayNames = map wayName . ways
  
@@@ -643,8 -720,8 +721,8 @@@ initDynFlags dflags = d
  
  -- | The normal 'DynFlags'. Note that they is not suitable for use in this form
  -- and must be fully initialized by 'GHC.newSession' first.
- defaultDynFlags :: DynFlags
- defaultDynFlags =
+ defaultDynFlags :: Settings -> DynFlags
+ defaultDynFlags mySettings =
       DynFlags {
          ghcMode                 = CompManager,
          ghcLink                 = LinkBinary,
          libraryPaths            = [],
          frameworkPaths          = [],
          cmdlineFrameworks       = [],
-         tmpDir                  = cDEFAULT_TMPDIR,
          rtsOpts                 = Nothing,
          rtsOptsEnabled          = RtsOptsSafeOnly,
  
          hpcDir                  = ".hpc",
  
-         opt_L                   = [],
-         opt_P                   = (if opt_PIC
-                                    then ["-D__PIC__", "-U __PIC__"] -- this list is reversed
-                                    else []),
-         opt_F                   = [],
-         opt_c                   = [],
-         opt_a                   = [],
-         opt_m                   = [],
-         opt_l                   = [],
-         opt_windres             = [],
-         opt_lo                  = [],
-         opt_lc                  = [],
          extraPkgConfs           = [],
          packageFlags            = [],
          pkgDatabase             = Nothing,
          buildTag                = panic "defaultDynFlags: No buildTag",
          rtsBuildTag             = panic "defaultDynFlags: No rtsBuildTag",
          splitInfo               = Nothing,
-         -- initSysTools fills all these in
-         ghcUsagePath            = panic "defaultDynFlags: No ghciUsagePath",
-         ghciUsagePath           = panic "defaultDynFlags: No ghciUsagePath",
-         topDir                  = panic "defaultDynFlags: No topDir",
-         systemPackageConfig     = panic  "no systemPackageConfig: call GHC.setSessionDynFlags",
-         pgm_L                   = panic "defaultDynFlags: No pgm_L",
-         pgm_P                   = panic "defaultDynFlags: No pgm_P",
-         pgm_F                   = panic "defaultDynFlags: No pgm_F",
-         pgm_c                   = panic "defaultDynFlags: No pgm_c",
-         pgm_s                   = panic "defaultDynFlags: No pgm_s",
-         pgm_a                   = panic "defaultDynFlags: No pgm_a",
-         pgm_l                   = panic "defaultDynFlags: No pgm_l",
-         pgm_dll                 = panic "defaultDynFlags: No pgm_dll",
-         pgm_T                   = panic "defaultDynFlags: No pgm_T",
-         pgm_sysman              = panic "defaultDynFlags: No pgm_sysman",
-         pgm_windres             = panic "defaultDynFlags: No pgm_windres",
-         pgm_lo                  = panic "defaultDynFlags: No pgm_lo",
-         pgm_lc                  = panic "defaultDynFlags: No pgm_lc",
-         -- end of initSysTools values
+         settings                = mySettings,
          -- ghc -M values
          depMakefile       = "Makefile",
          depIncludePkgDeps = False,
@@@ -913,9 -958,9 +959,9 @@@ setDumpPrefixForce f d = d { dumpPrefix
  
  -- XXX HACK: Prelude> words "'does not' work" ===> ["'does","not'","work"]
  -- Config.hs should really use Option.
- setPgmP   f d = let (pgm:args) = words f in d{ pgm_P   = (pgm, map Option args)}
- addOptl   f d = d{ opt_l   = f : opt_l d}
- addOptP   f d = d{ opt_P   = f : opt_P d}
+ setPgmP   f = let (pgm:args) = words f in alterSettings (\s -> s { sPgm_P   = (pgm, map Option args)})
+ addOptl   f = alterSettings (\s -> s { sOpt_l   = f : sOpt_l s})
+ addOptP   f = alterSettings (\s -> s { sOpt_P   = f : sOpt_P s})
  
  
  setDepMakefile :: FilePath -> DynFlags -> DynFlags
@@@ -1096,30 -1141,30 +1142,30 @@@ dynamic_flags = 
  
          ------- Specific phases  --------------------------------------------
      -- need to appear before -pgmL to be parsed as LLVM flags.
-   , Flag "pgmlo"          (hasArg (\f d -> d{ pgm_lo  = (f,[])}))
-   , Flag "pgmlc"          (hasArg (\f d -> d{ pgm_lc  = (f,[])}))
-   , Flag "pgmL"           (hasArg (\f d -> d{ pgm_L   = f}))
+   , Flag "pgmlo"          (hasArg (\f -> alterSettings (\s -> s { sPgm_lo  = (f,[])})))
+   , Flag "pgmlc"          (hasArg (\f -> alterSettings (\s -> s { sPgm_lc  = (f,[])})))
+   , Flag "pgmL"           (hasArg (\f -> alterSettings (\s -> s { sPgm_L   = f})))
    , Flag "pgmP"           (hasArg setPgmP)
-   , Flag "pgmF"           (hasArg (\f d -> d{ pgm_F   = f}))
-   , Flag "pgmc"           (hasArg (\f d -> d{ pgm_c   = (f,[])}))
+   , Flag "pgmF"           (hasArg (\f -> alterSettings (\s -> s { sPgm_F   = f})))
+   , Flag "pgmc"           (hasArg (\f -> alterSettings (\s -> s { sPgm_c   = (f,[])})))
    , Flag "pgmm"           (HasArg (\_ -> addWarn "The -keep-raw-s-files flag does nothing; it will be removed in a future GHC release"))
-   , Flag "pgms"           (hasArg (\f d -> d{ pgm_s   = (f,[])}))
-   , Flag "pgma"           (hasArg (\f d -> d{ pgm_a   = (f,[])}))
-   , Flag "pgml"           (hasArg (\f d -> d{ pgm_l   = (f,[])}))
-   , Flag "pgmdll"         (hasArg (\f d -> d{ pgm_dll = (f,[])}))
-   , Flag "pgmwindres"     (hasArg (\f d -> d{ pgm_windres = f}))
+   , Flag "pgms"           (hasArg (\f -> alterSettings (\s -> s { sPgm_s   = (f,[])})))
+   , Flag "pgma"           (hasArg (\f -> alterSettings (\s -> s { sPgm_a   = (f,[])})))
+   , Flag "pgml"           (hasArg (\f -> alterSettings (\s -> s { sPgm_l   = (f,[])})))
+   , Flag "pgmdll"         (hasArg (\f -> alterSettings (\s -> s { sPgm_dll = (f,[])})))
+   , Flag "pgmwindres"     (hasArg (\f -> alterSettings (\s -> s { sPgm_windres = f})))
  
      -- need to appear before -optl/-opta to be parsed as LLVM flags.
-   , Flag "optlo"          (hasArg (\f d -> d{ opt_lo  = f : opt_lo d}))
-   , Flag "optlc"          (hasArg (\f d -> d{ opt_lc  = f : opt_lc d}))
-   , Flag "optL"           (hasArg (\f d -> d{ opt_L   = f : opt_L d}))
+   , Flag "optlo"          (hasArg (\f -> alterSettings (\s -> s { sOpt_lo  = f : sOpt_lo s})))
+   , Flag "optlc"          (hasArg (\f -> alterSettings (\s -> s { sOpt_lc  = f : sOpt_lc s})))
+   , Flag "optL"           (hasArg (\f -> alterSettings (\s -> s { sOpt_L   = f : sOpt_L s})))
    , Flag "optP"           (hasArg addOptP)
-   , Flag "optF"           (hasArg (\f d -> d{ opt_F   = f : opt_F d}))
-   , Flag "optc"           (hasArg (\f d -> d{ opt_c   = f : opt_c d}))
-   , Flag "optm"           (hasArg (\f d -> d{ opt_m   = f : opt_m d}))
-   , Flag "opta"           (hasArg (\f d -> d{ opt_a   = f : opt_a d}))
+   , Flag "optF"           (hasArg (\f -> alterSettings (\s -> s { sOpt_F   = f : sOpt_F s})))
+   , Flag "optc"           (hasArg (\f -> alterSettings (\s -> s { sOpt_c   = f : sOpt_c s})))
+   , Flag "optm"           (hasArg (\f -> alterSettings (\s -> s { sOpt_m   = f : sOpt_m s})))
+   , Flag "opta"           (hasArg (\f -> alterSettings (\s -> s { sOpt_a   = f : sOpt_a s})))
    , Flag "optl"           (hasArg addOptl)
-   , Flag "optwindres"     (hasArg (\f d -> d{ opt_windres = f : opt_windres d}))
+   , Flag "optwindres"     (hasArg (\f -> alterSettings (\s -> s { sOpt_windres = f : sOpt_windres s})))
  
    , Flag "split-objs"
           (NoArg (if can_split 
    , Flag "fcontext-stack"              (intSuffix (\n d -> d{ ctxtStkDepth = n }))
    , Flag "fstrictness-before"          (intSuffix (\n d -> d{ strictnessBefore = n : strictnessBefore d }))
    , Flag "ffloat-lam-args"             (intSuffix (\n d -> d{ floatLamArgs = Just n }))
-   , Flag "ffloat-all-lams"             (intSuffix (\n d -> d{ floatLamArgs = Nothing }))
+   , Flag "ffloat-all-lams"             (noArg (\d -> d{ floatLamArgs = Nothing }))
  
          ------ Profiling ----------------------------------------------------
  
@@@ -1570,7 -1615,6 +1616,7 @@@ xFlags = 
    ( "EmptyDataDecls",                   Opt_EmptyDataDecls, nop ),
    ( "ParallelListComp",                 Opt_ParallelListComp, nop ),
    ( "TransformListComp",                Opt_TransformListComp, nop ),
 +  ( "MonadComprehensions",              Opt_MonadComprehensions, nop),
    ( "ForeignFunctionInterface",         Opt_ForeignFunctionInterface, nop ),
    ( "UnliftedFFITypes",                 Opt_UnliftedFFITypes, nop ),
    ( "GHCForeignImportPrim",             Opt_GHCForeignImportPrim, nop ),
@@@ -1835,18 -1879,20 +1881,20 @@@ foreign import ccall unsafe "rts_isProf
  
  rtsIsProfiled :: Bool
  rtsIsProfiled = unsafePerformIO rtsIsProfiledIO /= 0
+ #endif
  
  checkTemplateHaskellOk :: Bool -> DynP ()
- checkTemplateHaskellOk turn_on 
+ #ifdef GHCI
+ checkTemplateHaskellOk turn_on
    | turn_on && rtsIsProfiled
    = addErr "You can't use Template Haskell with a profiled compiler"
    | otherwise
    = return ()
  #else
- -- In stage 1 we don't know that the RTS has rts_isProfiled, 
+ -- In stage 1 we don't know that the RTS has rts_isProfiled,
  -- so we simply say "ok".  It doesn't matter because TH isn't
  -- available in stage 1 anyway.
- checkTemplateHaskellOk turn_on = return ()
+ checkTemplateHaskellOk _ = return ()
  #endif
  
  {- **********************************************************************
@@@ -1903,6 -1949,10 +1951,10 @@@ unSetExtensionFlag f = upd (\dfs -> xop
     --      (except for -fno-glasgow-exts, which is treated specially)
  
  --------------------------
+ alterSettings :: (Settings -> Settings) -> DynFlags -> DynFlags
+ alterSettings f dflags = dflags { settings = f (settings dflags) }
+ --------------------------
  setDumpFlag' :: DynFlag -> DynP ()
  setDumpFlag' dump_flag
    = do { setDynFlag dump_flag
@@@ -2117,7 -2167,7 +2169,7 @@@ splitPathList s = filter notNull (split
  -- tmpDir, where we store temporary files.
  
  setTmpDir :: FilePath -> DynFlags -> DynFlags
- setTmpDir dir dflags = dflags{ tmpDir = normalise dir }
+ setTmpDir dir = alterSettings (\s -> s { sTmpDir = normalise dir })
    -- we used to fix /cygdrive/c/.. on Windows, but this doesn't
    -- seem necessary now --SDM 7/2/2008
  
@@@ -2142,17 -2192,16 +2194,16 @@@ setOptHpcDir arg  = upd $ \ d -> d{hpcD
  -- There are some options that we need to pass to gcc when compiling
  -- Haskell code via C, but are only supported by recent versions of
  -- gcc.  The configure script decides which of these options we need,
- -- and puts them in the file "extra-gcc-opts" in $topdir, which is
- -- read before each via-C compilation.  The advantage of having these
- -- in a separate file is that the file can be created at install-time
- -- depending on the available gcc version, and even re-generated  later
- -- if gcc is upgraded.
+ -- and puts them in the "settings" file in $topdir. The advantage of
+ -- having these in a separate file is that the file can be created at
+ -- install-time depending on the available gcc version, and even
+ -- re-generated later if gcc is upgraded.
  --
  -- The options below are not dependent on the version of gcc, only the
  -- platform.
  
  machdepCCOpts :: DynFlags -> [String] -- flags for all C compilations
- machdepCCOpts dflags = cCcOpts ++ machdepCCOpts'
+ machdepCCOpts _ = cCcOpts ++ machdepCCOpts'
  
  machdepCCOpts' :: [String] -- flags for all C compilations
  machdepCCOpts'
@@@ -2224,30 -2273,35 +2275,35 @@@ can_split = cSupportsSplitObjs == "YES
  -- -----------------------------------------------------------------------------
  -- Compiler Info
  
- data Printable = String String
-                | FromDynFlags (DynFlags -> String)
- compilerInfo :: [(String, Printable)]
- compilerInfo = [("Project name",                String cProjectName),
-                 ("Project version",             String cProjectVersion),
-                 ("Booter version",              String cBooterVersion),
-                 ("Stage",                       String cStage),
-                 ("Build platform",              String cBuildPlatformString),
-                 ("Host platform",               String cHostPlatformString),
-                 ("Target platform",             String cTargetPlatformString),
-                 ("Have interpreter",            String cGhcWithInterpreter),
-                 ("Object splitting supported",  String cSupportsSplitObjs),
-                 ("Have native code generator",  String cGhcWithNativeCodeGen),
-                 ("Support SMP",                 String cGhcWithSMP),
-                 ("Unregisterised",              String cGhcUnregisterised),
-                 ("Tables next to code",         String cGhcEnableTablesNextToCode),
-                 ("RTS ways",                    String cGhcRTSWays),
-                 ("Leading underscore",          String cLeadingUnderscore),
-                 ("Debug on",                    String (show debugIsOn)),
-                 ("LibDir",                      FromDynFlags topDir),
-                 ("Global Package DB",           FromDynFlags systemPackageConfig),
-                 ("C compiler flags",            String (show cCcOpts)),
-                 ("Gcc Linker flags",            String (show cGccLinkerOpts)),
-                 ("Ld Linker flags",             String (show cLdLinkerOpts))
-                ]
+ compilerInfo :: DynFlags -> [(String, String)]
+ compilerInfo dflags
+     = -- We always make "Project name" be first to keep parsing in
+       -- other languages simple, i.e. when looking for other fields,
+       -- you don't have to worry whether there is a leading '[' or not
+       ("Project name",                 cProjectName)
+       -- Next come the settings, so anything else can be overridden
+       -- in the settings file (as "lookup" uses the first match for the
+       -- key)
+     : rawSettings dflags
+    ++ [("Project version",             cProjectVersion),
+        ("Booter version",              cBooterVersion),
+        ("Stage",                       cStage),
+        ("Build platform",              cBuildPlatformString),
+        ("Host platform",               cHostPlatformString),
+        ("Target platform",             cTargetPlatformString),
+        ("Have interpreter",            cGhcWithInterpreter),
+        ("Object splitting supported",  cSupportsSplitObjs),
+        ("Have native code generator",  cGhcWithNativeCodeGen),
+        ("Support SMP",                 cGhcWithSMP),
+        ("Unregisterised",              cGhcUnregisterised),
+        ("Tables next to code",         cGhcEnableTablesNextToCode),
+        ("RTS ways",                    cGhcRTSWays),
+        ("Leading underscore",          cLeadingUnderscore),
+        ("Debug on",                    show debugIsOn),
+        ("LibDir",                      topDir dflags),
+        ("Global Package DB",           systemPackageConfig dflags),
+        ("C compiler flags",            show cCcOpts),
+        ("Gcc Linker flags",            show cGccLinkerOpts),
+        ("Ld Linker flags",             show cLdLinkerOpts)
+       ]
  
@@@ -1132,12 -1132,11 +1132,11 @@@ hscTcExpr    -- Typecheck an expression (b
  hscTcExpr hsc_env expr = runHsc hsc_env $ do
      maybe_stmt <- hscParseStmt expr
      case maybe_stmt of
-       Just (L _ (ExprStmt expr _ _ _)) ->
-           ioMsgMaybe $ tcRnExpr hsc_env (hsc_IC hsc_env) expr
-       _ -> 
-           liftIO $ throwIO $ mkSrcErr $ unitBag $ 
-               mkPlainErrMsg noSrcSpan
-                             (text "not an expression:" <+> quotes (text expr))
 -        Just (L _ (ExprStmt expr _ _)) ->
++        Just (L _ (ExprStmt expr _ _ _)) ->
+             ioMsgMaybe $ tcRnExpr hsc_env (hsc_IC hsc_env) expr
+         _ ->
+             liftIO $ throwIO $ mkSrcErr $ unitBag $ mkPlainErrMsg noSrcSpan
+                 (text "not an expression:" <+> quotes (text expr))
  
  -- | Find the kind of a type
  hscKcType
diff --combined compiler/parser/Lexer.x
@@@ -1856,7 -1856,7 +1856,7 @@@ pragState dynflags buf loc = (mkPState 
  mkPState :: DynFlags -> StringBuffer -> SrcLoc -> PState
  mkPState flags buf loc =
    PState {
-       buffer        = buf,
+       buffer        = buf,
        dflags        = flags,
        messages      = emptyMessages,
        last_loc      = mkSrcSpan loc loc,
        alr_justClosedExplicitLetBlock = False
      }
      where
-       bitmap = genericsBit `setBitIf` xopt Opt_Generics flags
-              .|. ffiBit            `setBitIf` xopt Opt_ForeignFunctionInterface flags
-              .|. parrBit           `setBitIf` xopt Opt_ParallelArrays  flags
-              .|. arrowsBit         `setBitIf` xopt Opt_Arrows          flags
-              .|. thBit             `setBitIf` xopt Opt_TemplateHaskell flags
-              .|. qqBit             `setBitIf` xopt Opt_QuasiQuotes     flags
-              .|. ipBit             `setBitIf` xopt Opt_ImplicitParams  flags
-              .|. explicitForallBit `setBitIf` xopt Opt_ExplicitForAll  flags
-              .|. bangPatBit        `setBitIf` xopt Opt_BangPatterns flags
-              .|. tyFamBit          `setBitIf` xopt Opt_TypeFamilies flags
-              .|. haddockBit        `setBitIf` dopt Opt_Haddock      flags
-              .|. magicHashBit      `setBitIf` xopt Opt_MagicHash    flags
-              .|. kindSigsBit       `setBitIf` xopt Opt_KindSignatures flags
-              .|. recursiveDoBit    `setBitIf` xopt Opt_RecursiveDo flags
-              .|. recBit            `setBitIf` xopt Opt_DoRec  flags
-              .|. recBit            `setBitIf` xopt Opt_Arrows flags
-              .|. unicodeSyntaxBit  `setBitIf` xopt Opt_UnicodeSyntax flags
-              .|. unboxedTuplesBit  `setBitIf` xopt Opt_UnboxedTuples flags
+       bitmap =     genericsBit       `setBitIf` xopt Opt_Generics flags
+                .|. ffiBit            `setBitIf` xopt Opt_ForeignFunctionInterface flags
+                .|. parrBit           `setBitIf` xopt Opt_ParallelArrays  flags
+                .|. arrowsBit         `setBitIf` xopt Opt_Arrows          flags
+                .|. thBit             `setBitIf` xopt Opt_TemplateHaskell flags
+                .|. qqBit             `setBitIf` xopt Opt_QuasiQuotes     flags
+                .|. ipBit             `setBitIf` xopt Opt_ImplicitParams  flags
+                .|. explicitForallBit `setBitIf` xopt Opt_ExplicitForAll  flags
+                .|. bangPatBit        `setBitIf` xopt Opt_BangPatterns    flags
+                .|. tyFamBit          `setBitIf` xopt Opt_TypeFamilies    flags
+                .|. haddockBit        `setBitIf` dopt Opt_Haddock         flags
+                .|. magicHashBit      `setBitIf` xopt Opt_MagicHash       flags
+                .|. kindSigsBit       `setBitIf` xopt Opt_KindSignatures  flags
+                .|. recursiveDoBit    `setBitIf` xopt Opt_RecursiveDo     flags
+                .|. recBit            `setBitIf` xopt Opt_DoRec           flags
+                .|. recBit            `setBitIf` xopt Opt_Arrows          flags
+                .|. unicodeSyntaxBit  `setBitIf` xopt Opt_UnicodeSyntax   flags
+                .|. unboxedTuplesBit  `setBitIf` xopt Opt_UnboxedTuples   flags
                 .|. datatypeContextsBit `setBitIf` xopt Opt_DatatypeContexts flags
                 .|. transformComprehensionsBit `setBitIf` xopt Opt_TransformListComp flags
 +               .|. transformComprehensionsBit `setBitIf` xopt Opt_MonadComprehensions flags
                 .|. rawTokenStreamBit `setBitIf` dopt Opt_KeepRawTokenStream flags
                 .|. alternativeLayoutRuleBit `setBitIf` xopt Opt_AlternativeLayoutRule flags
-                .|. relaxedLayoutBit `setBitIf` xopt Opt_RelaxedLayout flags
+                .|. relaxedLayoutBit  `setBitIf` xopt Opt_RelaxedLayout flags
                 .|. nondecreasingIndentationBit `setBitIf` xopt Opt_NondecreasingIndentation flags
        --
        setBitIf :: Int -> Bool -> Int
        b `setBitIf` cond | cond      = bit b
-                       | otherwise = 0
+                         | otherwise = 0
  
  addWarning :: DynFlag -> SrcSpan -> SDoc -> P ()
  addWarning option srcspan warning
@@@ -639,7 -639,7 +639,7 @@@ plusImportAvail
    (ImportAvails { imp_mods = mods2,
                  imp_dep_mods = dmods2, imp_dep_pkgs = dpkgs2,
                    imp_orphs = orphs2, imp_finsts = finsts2 })
-   = ImportAvails { imp_mods     = plusModuleEnv_C (++) mods1 mods2,   
+   = ImportAvails { imp_mods     = plusModuleEnv_C (++) mods1 mods2,
                   imp_dep_mods = plusUFM_C plus_mod_dep dmods1 dmods2, 
                   imp_dep_pkgs = dpkgs1 `unionLists` dpkgs2,
                   imp_orphs    = orphs1 `unionLists` orphs2,
@@@ -1112,7 -1112,6 +1112,7 @@@ data CtOrigi
    | StandAloneDerivOrigin -- Typechecking stand-alone deriving
    | DefaultOrigin     -- Typechecking a default decl
    | DoOrigin          -- Arising from a do expression
 +  | MCompOrigin         -- Arising from a monad comprehension
    | IfOrigin            -- Arising from an if statement
    | ProcOrigin                -- Arising from a proc expression
    | AnnOrigin           -- An annotation
@@@ -1148,7 -1147,6 +1148,7 @@@ pprO DerivOrigin           = ptext (sLit "the 
  pprO StandAloneDerivOrigin = ptext (sLit "a 'deriving' declaration")
  pprO DefaultOrigin       = ptext (sLit "a 'default' declaration")
  pprO DoOrigin            = ptext (sLit "a do statement")
 +pprO MCompOrigin           = ptext (sLit "a statement in a monad comprehension")
  pprO ProcOrigin                  = ptext (sLit "a proc expression")
  pprO (TypeEqOrigin eq)     = ptext (sLit "an equality") <+> ppr eq
  pprO AnnOrigin             = ptext (sLit "an annotation")
              <entry>dynamic</entry>
              <entry><option>-XNoTransformListComp</option></entry>
            </row>
 +        <row>
 +            <entry><option>-XMonadComprehensions</option></entry>
 +            <entry>Enable <link linkend="monad-comprehensions">monad comprehensions</link>.</entry>
 +            <entry>dynamic</entry>
 +            <entry><option>-XNoMonadComprehensions</option></entry>
 +          </row>
            <row>
              <entry><option>-XUnliftedFFITypes</option></entry>
              <entry>Enable unlifted FFI types.</entry>
@@@ -2474,32 -2468,68 +2474,68 @@@ phase <replaceable>n</replaceable></ent
              <entry>-</entry>
            </row>
            <row>
+             <entry><option>-dppr-noprags</option></entry>
+             <entry>Don't output pragma info in dumps</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dppr-user-length</option></entry>
+             <entry>Set the depth for printing expressions in error msgs</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dppr-colsNNN</option></entry>
+             <entry>Set the width of debugging output. For example <option>-dppr-cols200</option></entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dppr-case-as-let</option></entry>
+             <entry>Print single alternative case expressions as strict lets.</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dsuppress-all</option></entry>
+             <entry>In core dumps, suppress everything that is suppressable.</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
              <entry><option>-dsuppress-uniques</option></entry>
-             <entry>Suppress the printing of uniques in debug output (easier to use <command>diff</command>.</entry>
+             <entry>Suppress the printing of uniques in debug output (easier to use <command>diff</command>)</entry>
              <entry>static</entry>
              <entry>-</entry>
            </row>
            <row>
-             <entry><option>-dsuppress-coercions</option></entry>
-             <entry>Suppress the printing of coercions in Core dumps to make them shorter.</entry>
+             <entry><option>-dsuppress-idinfo</option></entry>
+             <entry>Suppress extended information about identifiers where they are bound</entry>
              <entry>static</entry>
              <entry>-</entry>
            </row>
            <row>
              <entry><option>-dsuppress-module-prefixes</option></entry>
-             <entry>Suppress the printing of module qualification prefixes in Core dumps to make them easier to read.</entry>
+             <entry>Suppress the printing of module qualification prefixes</entry>
              <entry>static</entry>
              <entry>-</entry>
            </row>
            <row>
-             <entry><option>-dppr-noprags</option></entry>
-             <entry>Don't output pragma info in dumps</entry>
+             <entry><option>-dsuppress-type-signatures</option></entry>
+             <entry>Suppress type signatures</entry>
              <entry>static</entry>
              <entry>-</entry>
            </row>
            <row>
-             <entry><option>-dppr-user-length</option></entry>
-             <entry>Set the depth for printing expressions in error msgs</entry>
+             <entry><option>-dsuppress-type-applications</option></entry>
+             <entry>Suppress type applications</entry>
+             <entry>static</entry>
+             <entry>-</entry>
+           </row>
+           <row>
+             <entry><option>-dsuppress-coercions</option></entry>
+             <entry>Suppress the printing of coercions in Core dumps to make them shorter</entry>
              <entry>static</entry>
              <entry>-</entry>
            </row>