summaryrefslogtreecommitdiff
path: root/compiler/ghci/InteractiveUI.hs
diff options
context:
space:
mode:
authorPepe Iborra <mnislaih@gmail.com>2007-12-08 18:09:18 +0000
committerPepe Iborra <mnislaih@gmail.com>2007-12-08 18:09:18 +0000
commitcf71c5a6df7c7fea777da0e0b91e937538287caa (patch)
tree127110006efef6ab25d9a6021b8714b993d5ece6 /compiler/ghci/InteractiveUI.hs
parent4d71f5ee6dbbfedb4a55767e4375f4c0aadf70bb (diff)
downloadhaskell-cf71c5a6df7c7fea777da0e0b91e937538287caa.tar.gz
Help the user when she tries to do :history without :trace
Teach GHCi to show a "perhaps you forgot to use :trace?" when it finds that the user is trying to retrieve an empty :history
Diffstat (limited to 'compiler/ghci/InteractiveUI.hs')
-rw-r--r--compiler/ghci/InteractiveUI.hs22
1 files changed, 13 insertions, 9 deletions
diff --git a/compiler/ghci/InteractiveUI.hs b/compiler/ghci/InteractiveUI.hs
index 8cc15132a8..4c9bac04cf 100644
--- a/compiler/ghci/InteractiveUI.hs
+++ b/compiler/ghci/InteractiveUI.hs
@@ -1912,15 +1912,19 @@ historyCmd arg
(r:_) -> do
let hist = GHC.resumeHistory r
(took,rest) = splitAt num hist
- spans <- mapM (io . GHC.getHistorySpan s) took
- let nums = map (printf "-%-3d:") [(1::Int)..]
- let names = map GHC.historyEnclosingDecl took
- printForUser (vcat(zipWith3
- (\x y z -> x <+> y <+> z)
- (map text nums)
- (map (bold . ppr) names)
- (map (parens . ppr) spans)))
- io $ putStrLn $ if null rest then "<end of history>" else "..."
+ case hist of
+ [] -> io $ putStrLn $
+ "Empty history. Perhaps you forgot to use :trace?"
+ _ -> do
+ spans <- mapM (io . GHC.getHistorySpan s) took
+ let nums = map (printf "-%-3d:") [(1::Int)..]
+ names = map GHC.historyEnclosingDecl took
+ printForUser (vcat(zipWith3
+ (\x y z -> x <+> y <+> z)
+ (map text nums)
+ (map (bold . ppr) names)
+ (map (parens . ppr) spans)))
+ io $ putStrLn $ if null rest then "<end of history>" else "..."
bold :: SDoc -> SDoc
bold c | do_bold = text start_bold <> c <> text end_bold