diff options
author | Vitaly Bragilesky <bravit111@gmail.com> | 2012-06-21 12:26:29 +0400 |
---|---|---|
committer | Paolo Capriotti <p.capriotti@gmail.com> | 2012-06-25 12:30:25 +0100 |
commit | bec0737c9a96eb19f521a07de615366433ce6a4d (patch) | |
tree | 0533990615b44ebcb30a3c67be89228b72ea03d8 /ghc | |
parent | 66c41963c82ae66a24c5d7b96f5fa6e797d6a27d (diff) | |
download | haskell-bec0737c9a96eb19f521a07de615366433ce6a4d.tar.gz |
Implemented feature request on reconfigurable pretty-printing in GHCi (#5461)
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/InteractiveUI.hs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs index 049b79eba9..32316341e1 100644 --- a/ghc/InteractiveUI.hs +++ b/ghc/InteractiveUI.hs @@ -450,6 +450,8 @@ runGHCi paths maybe_exprs = do when (isJust maybe_exprs && failed ok) $ liftIO (exitWith (ExitFailure 1)) + installInteractivePrint (interactivePrint dflags) (isJust maybe_exprs) + -- if verbosity is greater than 0, or we are connected to a -- terminal, display the prompt in the interactive loop. is_tty <- liftIO (hIsTerminalDevice stdin) @@ -607,6 +609,18 @@ queryQueue = do c:cs -> do setGHCiState st{ cmdqueue = cs } return (Just c) +-- Reconfigurable pretty-printing Ticket #5461 +installInteractivePrint :: Maybe String -> Bool -> GHCi () +installInteractivePrint Nothing _ = return () +installInteractivePrint (Just ipFun) exprmode = do + ok <- trySuccess $ do + (name:_) <- GHC.parseName ipFun + dflags <- getDynFlags + GHC.setInteractiveDynFlags (setInteractivePrintName name dflags) + return Succeeded + + when (failed ok && exprmode) $ liftIO (exitWith (ExitFailure 1)) + -- | The main read-eval-print loop runCommands :: InputT GHCi (Maybe String) -> InputT GHCi () runCommands = runCommands' handler @@ -1975,6 +1989,7 @@ newDynFlags interactive_only minus_opts = do packageFlags idflags1 /= packageFlags idflags0) $ do liftIO $ hPutStrLn stderr "cannot set package flags with :seti; use :set" GHC.setInteractiveDynFlags idflags1 + installInteractivePrint (interactivePrint idflags1) False dflags0 <- getDynFlags when (not interactive_only) $ do |