#3217: Make GHCi have separate flags for interactive Haskell expressions
---------------------------------+------------------------------------------
    Reporter:  simonpj           |       Owner:                  
        Type:  feature request   |      Status:  new             
    Priority:  high              |   Milestone:  7.4.2           
   Component:  Compiler          |     Version:  6.10.2          
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:  3202            
     Related:                    |  
---------------------------------+------------------------------------------

Comment(by marlowsd@…):

 commit 2e55760b856540535fa0e4fe1805a75eea7d6b45
 {{{
 Author: Simon Marlow <[email protected]>
 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
         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.

  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(-)
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3217#comment:28>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to