X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fghci%2FInteractiveUI.hs;h=51fcd8e8d39644df9f3940b26db5aed758efdc23;hb=6189bc57f7baf2a2dda8c714cf32e29792c708b7;hp=2aa1c673fdab01d6400b841730c8573d00d1ec49;hpb=2bf08ae10e95b0ea98189118f6801dc3c62aa495;p=ghc-hetmet.git diff --git a/ghc/compiler/ghci/InteractiveUI.hs b/ghc/compiler/ghci/InteractiveUI.hs index 2aa1c67..51fcd8e 100644 --- a/ghc/compiler/ghci/InteractiveUI.hs +++ b/ghc/compiler/ghci/InteractiveUI.hs @@ -1,236 +1,1166 @@ +{-# OPTIONS -#include "Linker.h" #-} ----------------------------------------------------------------------------- --- $Id: InteractiveUI.hs,v 1.3 2000/11/16 16:54:36 simonmar Exp $ -- -- GHC Interactive User Interface -- --- (c) The GHC Team 2000 +-- (c) The GHC Team 2005 -- ----------------------------------------------------------------------------- - -module InteractiveUI (interactiveUI) where +module InteractiveUI ( + interactiveUI, + ghciWelcomeMsg + ) where #include "HsVersions.h" -import CompManager -import CmStaticInfo -import DriverUtil -import DriverState -import Linker -import Module -import RdrName -- tmp -import OccName -- tmp -import Panic -import Util +-- The GHC interface +import qualified GHC +import GHC ( Session, verbosity, dopt, DynFlag(..), + mkModule, pprModule, Type, Module, SuccessFlag(..), + TyThing(..), Name ) +import Outputable + +-- following all needed for :info... ToDo: remove +import IfaceSyn ( IfaceDecl(..), IfaceClassOp(..), IfaceConDecls(..), + IfaceConDecl(..), IfaceType, + pprIfaceDeclHead, pprParendIfaceType, + pprIfaceForAllPart, pprIfaceType ) +import FunDeps ( pprFundeps ) +import SrcLoc ( SrcLoc, isGoodSrcLoc ) +import OccName ( OccName, parenSymOcc, occNameUserString ) +import BasicTypes ( StrictnessMark(..), defaultFixity ) + +-- Other random utilities +import Panic hiding ( showException ) +import Config +import StaticFlags ( opt_IgnoreDotGhci ) +import Linker ( showLinkerState ) +import Util ( removeSpaces, handle, global, toArgs, + looksLikeModuleName, prefixMatch ) + +#ifndef mingw32_HOST_OS +import Util ( handle ) +import System.Posix +#if __GLASGOW_HASKELL__ > 504 + hiding (getEnv) +#endif +#endif + +#ifdef USE_READLINE +import Control.Concurrent ( yield ) -- Used in readline loop +import System.Console.Readline as Readline +#endif + +--import SystemExts -import Exception -import Readline -import IOExts +import Control.Exception as Exception +import Data.Dynamic +-- import Control.Concurrent -import System -import Directory -import IO -import Char +import Numeric +import Data.List +import Data.Int ( Int64 ) +import System.Cmd +import System.CPUTime +import System.Environment +import System.Exit ( exitWith, ExitCode(..) ) +import System.Directory +import System.IO +import System.IO.Error as IO +import Data.Char +import Control.Monad as Monad +import Foreign.StablePtr ( newStablePtr ) -import PrelGHC ( unsafeCoerce# ) +import GHC.Exts ( unsafeCoerce# ) +import GHC.IOBase ( IOErrorType(InvalidArgument) ) + +import Data.IORef ( IORef, newIORef, readIORef, writeIORef ) + +import System.Posix.Internals ( setNonBlockingFD ) ----------------------------------------------------------------------------- -ghciWelcomeMsg = "\ -\ _____ __ __ ____ _________________________________________________\n\ -\(| || || (| |) GHC Interactive, version 5.00 \n\ -\|| __ ||___|| || () For Haskell 98. \n\ -\|| |) ||---|| || || http://www.haskell.org/ghc \n\ -\|| || || || || (| Bug reports to: glasgow-haskell-bugs@haskell.org \n\ -\(|___|| || || (|__|) \\\\______________________________________________________\n" - -commands :: [(String, String -> GHCi ())] -commands = [ - ("cd", changeDirectory), - ("help", help), - ("?", help), - ("load", loadModule), - ("reload", reloadModule), - ("set", setOptions), - ("type", typeOfExpr), - ("quit", quit), - ("!", shellEscape) +ghciWelcomeMsg = + " ___ ___ _\n"++ + " / _ \\ /\\ /\\/ __(_)\n"++ + " / /_\\// /_/ / / | | GHC Interactive, version " ++ cProjectVersion ++ ", for Haskell 98.\n"++ + "/ /_\\\\/ __ / /___| | http://www.haskell.org/ghc/\n"++ + "\\____/\\/ /_/\\____/|_| Type :? for help.\n" + +GLOBAL_VAR(commands, builtin_commands, [(String, String -> GHCi Bool)]) + +builtin_commands :: [(String, String -> GHCi Bool)] +builtin_commands = [ + ("add", keepGoingPaths addModule), + ("browse", keepGoing browseCmd), + ("cd", keepGoing changeDirectory), + ("def", keepGoing defineMacro), + ("help", keepGoing help), + ("?", keepGoing help), + ("info", keepGoing info), + ("load", keepGoingPaths loadModule), + ("module", keepGoing setContext), + ("reload", keepGoing reloadModule), + ("set", keepGoing setCmd), + ("show", keepGoing showCmd), + ("type", keepGoing typeOfExpr), + ("kind", keepGoing kindOfType), + ("unset", keepGoing unsetOptions), + ("undef", keepGoing undefineMacro), + ("quit", quit) ] +keepGoing :: (String -> GHCi ()) -> (String -> GHCi Bool) +keepGoing a str = a str >> return False + +keepGoingPaths :: ([FilePath] -> GHCi ()) -> (String -> GHCi Bool) +keepGoingPaths a str = a (toArgs str) >> return False + shortHelpText = "use :? for help.\n" -helpText = "\ -\ evaluate \n\ -\ :cd change directory to \n\ -\ :help display this list of commands\n\ -\ :? display this list of commands\n\ -\ :load load a module (and it dependents)\n\ -\ :reload reload the current program\n\ -\ :set ... set options\n\ -\ :type show the type of \n\ -\ :quit exit GHCi\n\ -\ :! run the shell command \n\ -\" - -interactiveUI :: CmState -> IO () -interactiveUI st = do - hPutStrLn stdout ghciWelcomeMsg +-- NOTE: spaces at the end of each line to workaround CPP/string gap bug. +helpText = + " Commands available from the prompt:\n" ++ + "\n" ++ + " evaluate/run \n" ++ + " :add ... add module(s) to the current target set\n" ++ + " :browse [*] display the names defined by \n" ++ + " :cd change directory to \n" ++ + " :def define a command :\n" ++ + " :help, :? display this list of commands\n" ++ + " :info [ ...] display information about the given names\n" ++ + " :load ... load module(s) and their dependents\n" ++ + " :module [+/-] [*] ... set the context for expression evaluation\n" ++ + " :reload reload the current module set\n" ++ + "\n" ++ + " :set