Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/bcfa64ac0d3167f765a632a721d6f6b741cd1c8a

>---------------------------------------------------------------

commit bcfa64ac0d3167f765a632a721d6f6b741cd1c8a
Author: Simon Peyton Jones <[email protected]>
Date:   Tue Aug 2 17:29:50 2011 +0100

    Wibble to main "Refactor the imports of InteractiveContext" patch

>---------------------------------------------------------------

 ghc/InteractiveUI.hs |   24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index 21d6abd..6cdce2c 100644
--- a/ghc/InteractiveUI.hs
+++ b/ghc/InteractiveUI.hs
@@ -1398,6 +1398,8 @@ browseModule bang modl exports_only = do
 
   -- Temporarily set the context to the module we're interested in,
   -- just so we can get an appropriate PrintUnqualified
+  -- Use mySetContext so we get an implicit Prelude import 
+  -- for the PrintUnqualified
   imports <- GHC.getContext
   lift $ mySetContext (if exports_only 
                        then [IIDecl $ simpleImportDecl (GHC.moduleName modl)]
@@ -1475,13 +1477,12 @@ browseModule bang modl exports_only = do
 
 -----------------------------------------------------------------------------
 -- Setting the module context
-
-newContextCmd :: CtxtCmd -> GHCi ()
-newContextCmd cmd = do
-  playCtxtCmds True [cmd]
-  st <- getGHCiState
-  let cmds = remembered_ctx st
-  setGHCiState st{ remembered_ctx = cmds ++ [cmd] }
+-- This handles  Command     Constructor in CtxtCmd
+--               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+--               :m X        SetContext
+--               :m +X       AddModules
+--               :m -X       RemModules    
+--               import X    Import
 
 moduleCmd :: String -> GHCi ()
 moduleCmd str
@@ -1504,11 +1505,18 @@ moduleCmd str
     starred ('*':m) = Left m
     starred m       = Right m
 
+newContextCmd :: CtxtCmd -> GHCi ()
+newContextCmd cmd = do
+  playCtxtCmds True [cmd]
+  st <- getGHCiState
+  let cmds = remembered_ctx st
+  setGHCiState st{ remembered_ctx = cmds ++ [cmd] }
+
 playCtxtCmds :: Bool -> [CtxtCmd] -> GHCi ()
 playCtxtCmds fail cmds = do
   ctx <- GHC.getContext
   ctx' <- foldM (playCtxtCmd fail) ctx cmds
-  mySetContext ctx'
+  mySetContext ctx'    -- Eliminate dups and add Prelude if not there
 
 playCtxtCmd:: Bool -> [InteractiveImport] -> CtxtCmd -> GHCi 
[InteractiveImport]
 playCtxtCmd fail prev cmd = do



_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to