- :type now prints names unqualified when possible.
- :module is implemented
-> DynFlags
-> ModuleName
-> String
-> DynFlags
-> ModuleName
-> String
- -> IO (CmState, Maybe Type)
+ -> IO (CmState, Maybe (PrintUnqualified, Type))
cmTypeExpr cmstate dflags modname expr
= do (new_pcs, expr_type) <-
hscTypeExpr dflags hst hit pcs (mkHomeModule modname) expr
cmTypeExpr cmstate dflags modname expr
= do (new_pcs, expr_type) <-
hscTypeExpr dflags hst hit pcs (mkHomeModule modname) expr
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
--- $Id: InteractiveUI.hs,v 1.10 2000/11/21 16:42:58 simonmar Exp $
+-- $Id: InteractiveUI.hs,v 1.11 2000/11/22 10:56:53 simonmar Exp $
--
-- GHC Interactive User Interface
--
--
-- GHC Interactive User Interface
--
commands :: [(String, String -> GHCi ())]
commands = [
commands :: [(String, String -> GHCi ())]
commands = [
("cd", changeDirectory),
("help", help),
("?", help),
("load", loadModule),
("cd", changeDirectory),
("help", help),
("?", help),
("load", loadModule),
+ ("module", setContext),
("reload", reloadModule),
("set", setOptions),
("type", typeOfExpr),
("reload", reloadModule),
("set", setOptions),
("type", typeOfExpr),
helpText = "\
\ <expr> evaluate <expr>\n\
helpText = "\
\ <expr> evaluate <expr>\n\
+\ :add <filename> add a module to the current set\n\
\ :cd <dir> change directory to <dir>\n\
\ :cd <dir> change directory to <dir>\n\
-\ :help display this list of commands\n\
-\ :? display this list of commands\n\
+\ :help, :? display this list of commands\n\
\ :load <filename> load a module (and it dependents)\n\
\ :load <filename> load a module (and it dependents)\n\
-\ :reload reload the current program\n\
+\ :module <mod> set the context for expression evaluation to <mod>\n\
+\ :reload reload the current module set\n\
\ :set <opetion> ... set options\n\
\ :type <expr> show the type of <expr>\n\
\ :quit exit GHCi\n\
\ :set <opetion> ... set options\n\
\ :type <expr> show the type of <expr>\n\
\ :quit exit GHCi\n\
help :: String -> GHCi ()
help _ = io (putStr helpText)
help :: String -> GHCi ()
help _ = io (putStr helpText)
+addModule :: String -> GHCi ()
+addModule _ = throwDyn (OtherError ":add not implemented")
+
+setContext :: String -> GHCi ()
+setContext ""
+ = throwDyn (OtherError "syntax: `:m <module>'")
+setContext m | not (isUpper (head m)) || not (all isAlphaNum (tail m))
+ = throwDyn (OtherError ("strange looking module name: `" ++ m ++ "'"))
+setContext m
+ = do st <- getGHCiState
+ setGHCiState st{current_module = mkModuleName m}
+
changeDirectory :: String -> GHCi ()
changeDirectory = io . setCurrentDirectory
changeDirectory :: String -> GHCi ()
changeDirectory = io . setCurrentDirectory
(current_module st) str)
case maybe_ty of
Nothing -> return ()
(current_module st) str)
case maybe_ty of
Nothing -> return ()
- Just ty -> io (putStrLn (showSDoc (ppr ty)))
+ Just (unqual, ty) -> io (printForUser stdout unqual (ppr ty))
quit :: String -> GHCi ()
quit _ = exitGHCi
quit :: String -> GHCi ()
quit _ = exitGHCi
-> PersistentCompilerState -- IN: persistent compiler state
-> Module -- Context for compiling
-> String -- The expression
-> PersistentCompilerState -- IN: persistent compiler state
-> Module -- Context for compiling
-> String -- The expression
- -> IO (PersistentCompilerState, Maybe Type)
+ -> IO (PersistentCompilerState, Maybe (PrintUnqualified, Type))
hscTypeExpr dflags hst hit pcs0 this_module expr
= do (pcs1, maybe_tc_result)
<- hscExprFrontEnd dflags hst hit pcs0 this_module expr
case maybe_tc_result of
Nothing -> return (pcs1, Nothing)
hscTypeExpr dflags hst hit pcs0 this_module expr
= do (pcs1, maybe_tc_result)
<- hscExprFrontEnd dflags hst hit pcs0 this_module expr
case maybe_tc_result of
Nothing -> return (pcs1, Nothing)
- Just (_,_,ty) -> return (pcs1, Just ty)
+ Just (print_unqual,_,ty) -> return (pcs1, Just (print_unqual,ty))
hscParseExpr :: DynFlags -> String -> IO (Maybe RdrNameHsExpr)
hscParseExpr dflags str
hscParseExpr :: DynFlags -> String -> IO (Maybe RdrNameHsExpr)
hscParseExpr dflags str