[commit: ghc] master: GHCi: add :seti, for options that apply only at the prompt (#3217) (2e55760)
marlowsd at gmail.com
Thu Mar 1 12:58:19 CET 2012
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : master
Author: Simon Marlow <marlowsd at gmail.com>
Date: Wed Feb 29 16:23:08 2012 +0000
GHCi: add :seti, for options that apply only at the prompt (#3217)
GHCi now maintains two DynFlags: one that applies to whole modules
loaded with :load, and one that applies to things typed at the prompt
(expressions, statements, declarations, commands).
The :set command modifies both DynFlags. This is for backwards
compatibility: users won't notice any difference.
The :seti command applies only to the interactive DynFlags.
Additionally, I made a few changes to ":set" (with no arguments):
* Now it only prints out options that differ from the defaults,
rather than the whole list.
* There is a new variant, ":set -a" to print out all options (the
* It also prints out language options.
options currently set: none.
base language is: Haskell2010
with the following modifiers:
GHCi-specific dynamic flag settings:
other dynamic, non-language, flag settings:
":seti" (with no arguments) does the same as ":set", but for the
interactive options. It also has the "-a" option.
The interactive DynFlags are kept in the InteractiveContext, and
copied into the HscEnv at the appropriate points (all in HscMain).
There are some new GHC API operations:
-- | Set the 'DynFlags' used to evaluate interactive expressions.
setInteractiveDynFlags :: GhcMonad m => DynFlags -> m ()
-- | Get the 'DynFlags' used to evaluate interactive expressions.
getInteractiveDynFlags :: GhcMonad m => m DynFlags
-- | Sets the program 'DynFlags'.
setProgramDynFlags :: GhcMonad m => DynFlags -> m [PackageId]
-- | Returns the program 'DynFlags'.
getProgramDynFlags :: GhcMonad m => m DynFlags
Note I have not completed the whole of the plan outlined in #3217 yet:
when in the context of a loaded module we don't take the interactive
DynFlags from that module. That needs some more refactoring and
thinking about, because we'll need to save and restore the original
This solves the immediate problem that people are having with the new
flag checking in 7.4.1, because now it is possible to set language
options in ~/.ghci that do not affect loaded modules and thereby cause
compiler/main/DynFlags.hs | 17 ++--
compiler/main/GHC.hs | 63 ++++++++++--
compiler/main/GhcMake.hs | 15 ++-
compiler/main/HscMain.hs | 52 ++++++---
compiler/main/HscTypes.lhs | 11 ++-
compiler/main/InteractiveEval.hs | 17 +--
compiler/typecheck/TcEnv.lhs | 8 +-
compiler/typecheck/TcSMonad.lhs | 4 +-
docs/users_guide/ghci.xml | 98 +++++++++++++++++-
ghc/GhciMonad.hs | 6 +-
ghc/InteractiveUI.hs | 218 ++++++++++++++++++++++++++------------
ghc/Main.hs | 2 +
12 files changed, 378 insertions(+), 133 deletions(-)
Diff suppressed because of size. To see it, use:
git show 2e55760b856540535fa0e4fe1805a75eea7d6b45
More information about the Cvs-ghc