diff options
author | Simon Marlow <marlowsd@gmail.com> | 2012-02-29 16:23:08 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2012-03-01 09:40:29 +0000 |
commit | 2e55760b856540535fa0e4fe1805a75eea7d6b45 (patch) | |
tree | dc1d0618d56e9ccae4fa676443e77a9554a323d3 /ghc/GhciMonad.hs | |
parent | 1eee2746f14fb44a5605017cea90114151c3d47f (diff) | |
download | haskell-2e55760b856540535fa0e4fe1805a75eea7d6b45.tar.gz |
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
old behaviour).
* It also prints out language options.
e.g.
Prelude> :set
options currently set: none.
base language is: Haskell2010
with the following modifiers:
-XNoDatatypeContexts
-XNondecreasingIndentation
GHCi-specific dynamic flag settings:
other dynamic, non-language, flag settings:
-fimplicit-import-qualified
warning 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
interactive DynFlags.
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
recompilation.
Diffstat (limited to 'ghc/GhciMonad.hs')
-rw-r--r-- | ghc/GhciMonad.hs | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/ghc/GhciMonad.hs b/ghc/GhciMonad.hs index 71d1e763d3..11d23a6876 100644 --- a/ghc/GhciMonad.hs +++ b/ghc/GhciMonad.hs @@ -16,7 +16,7 @@ module GhciMonad ( Command, BreakLocation(..), TickArray, - setDynFlags, + getDynFlags, runStmt, runDecls, resume, timeIt, recordBreak, revertCAFs, @@ -229,10 +229,6 @@ instance ExceptionMonad (InputT GHCi) where gblock = Haskeline.block gunblock = Haskeline.unblock -setDynFlags :: DynFlags -> GHCi [PackageId] -setDynFlags dflags = do - GHC.setSessionDynFlags dflags - isOptionSet :: GHCiOption -> GHCi Bool isOptionSet opt = do st <- getGHCiState |