diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index d745cd63afd933bb0c5264c6ba827c7621926493..4810ce85b1baff975ec0966228a03bce73b0adbf 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -670,6 +670,8 @@ data DynFlags = DynFlags { maxWorkerArgs :: Int, + ghciHistSize :: Int, + -- | MsgDoc output action: use "ErrUtils" instead of this if you can log_action :: LogAction, flushOut :: FlushOut, @@ -1227,6 +1229,8 @@ defaultDynFlags mySettings = maxWorkerArgs = 10, + ghciHistSize = 50, -- keep a log of length 50 by default + log_action = defaultLogAction, flushOut = defaultFlushOut, flushErr = defaultFlushErr, @@ -2126,6 +2130,8 @@ dynamic_flags = [ , Flag "fmax-worker-args" (intSuffix (\n d -> d {maxWorkerArgs = n})) + , Flag "fghci-hist-size" (intSuffix (\n d -> d {ghciHistSize = n})) + ------ Profiling ---------------------------------------------------- -- OLD profiling flags diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs index 64b2d3303c2ac41333c6854686e5d72a6dcc006d..9b9c14bb0b334c20c25166d8eb25007936ee84aa 100644 --- a/compiler/main/InteractiveEval.hs +++ b/compiler/main/InteractiveEval.hs @@ -220,13 +220,15 @@ runStmtWithLocation source linenumber expr step = let ic = hsc_IC hsc_env bindings = (ic_tythings ic, ic_rn_gbl_env ic) + size = ghciHistSize idflags' + case step of RunAndLogSteps -> traceRunStatus expr bindings tyThings - breakMVar statusMVar status emptyHistory + breakMVar statusMVar status (emptyHistory size) _other -> handleRunStatus expr bindings tyThings - breakMVar statusMVar status emptyHistory + breakMVar statusMVar status (emptyHistory size) runDecls :: GhcMonad m => String -> m [Name] runDecls = runDeclsWithLocation "" 1 @@ -268,8 +270,8 @@ withVirtualCWD m = do parseImportDecl :: GhcMonad m => String -> m (ImportDecl RdrName) parseImportDecl expr = withSession $ \hsc_env -> liftIO $ hscImport hsc_env expr -emptyHistory :: BoundedList History -emptyHistory = nilBL 50 -- keep a log of length 50 +emptyHistory :: Int -> BoundedList History +emptyHistory size = nilBL size handleRunStatus :: GhcMonad m => String-> ([TyThing],GlobalRdrEnv) -> [Id] diff --git a/docs/users_guide/flags.xml b/docs/users_guide/flags.xml index d670cb91a93eb6b4b46d00938e5be00eed6aeb5a..bc1c228e36db8c560a7404bb00090fd609e1d8a1 100644 --- a/docs/users_guide/flags.xml +++ b/docs/users_guide/flags.xml @@ -510,6 +510,12 @@ dynamic + + + Set the number of entries GHCi keeps for :history + dynamic + + Enable usage of Show instances in :print diff --git a/docs/users_guide/ghci.xml b/docs/users_guide/ghci.xml index 3d1aecc2fbba66ae667abc6f6a737eb61e6aa6aa..c59f4b38307d95f2f56aefe47affdb1eb48fe4ba 100644 --- a/docs/users_guide/ghci.xml +++ b/docs/users_guide/ghci.xml @@ -1715,8 +1715,7 @@ a :: a The history is only available when using :trace; the reason for this is we found that logging each breakpoint in the history cuts performance by a factor of - 2 or more. GHCi remembers the last 50 steps in the history (perhaps in - the future we'll make this configurable). + 2 or more. By default, GHCi remembers the last 50 steps in the history, but this can be changed with the option). @@ -2381,10 +2380,12 @@ Prelude> :. cmds.ghci :history - Display the history of evaluation steps. With a number, - displays that many steps (default: 20). For use with - :trace; see . + Display the history of evaluation steps. With a + number, displays that many steps (default: 20). For use + with :trace; see . To set the number of history entries stored by GHCi, + use + .