diff options
author | Vivian McPhail <haskell.vivian.mcphail@gmail.com> | 2011-02-26 07:31:33 +0000 |
---|---|---|
committer | Vivian McPhail <haskell.vivian.mcphail@gmail.com> | 2011-02-26 07:31:33 +0000 |
commit | eccb2d89eb4b34f31e8ea337d5f8673605f71665 (patch) | |
tree | dbf1de76ef655523c9e7daa818a570692bc6019e /compiler/main/InteractiveEval.hs | |
parent | 74430537272aecdc8fd85b4877cec76cc042c8ad (diff) | |
download | haskell-eccb2d89eb4b34f31e8ea337d5f8673605f71665.tar.gz |
:script file scripts in GHCi #1363
This patch adds the script command in GHCi
A file is read and executed as a series of GHCi commands.
Execution terminates on the first error. The filename and
line number are included in the error.
Diffstat (limited to 'compiler/main/InteractiveEval.hs')
-rw-r--r-- | compiler/main/InteractiveEval.hs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs index 43f6aa2c0e..e0a30b46dc 100644 --- a/compiler/main/InteractiveEval.hs +++ b/compiler/main/InteractiveEval.hs @@ -9,7 +9,8 @@ module InteractiveEval ( #ifdef GHCI RunResult(..), Status(..), Resume(..), History(..), - runStmt, parseImportDecl, SingleStep(..), + runStmt, runStmtWithLocation, + parseImportDecl, SingleStep(..), resume, abandon, abandonAll, getResumeContext, @@ -180,7 +181,13 @@ findEnclosingDecls hsc_env inf = -- | Run a statement in the current interactive context. Statement -- may bind multple values. runStmt :: GhcMonad m => String -> SingleStep -> m RunResult -runStmt expr step = +runStmt = runStmtWithLocation "<interactive>" 1 + +-- | Run a statement in the current interactive context. Passing debug information +-- Statement may bind multple values. +runStmtWithLocation :: GhcMonad m => String -> Int -> + String -> SingleStep -> m RunResult +runStmtWithLocation source linenumber expr step = do hsc_env <- getSession @@ -192,7 +199,7 @@ runStmt expr step = let dflags' = dopt_unset (hsc_dflags hsc_env) Opt_WarnUnusedBinds hsc_env' = hsc_env{ hsc_dflags = dflags' } - r <- liftIO $ hscStmt hsc_env' expr + r <- liftIO $ hscStmtWithLocation hsc_env' expr source linenumber case r of Nothing -> return RunFailed -- empty statement / comment |