summaryrefslogtreecommitdiff
path: root/ghc/GHCi/UI.hs
diff options
context:
space:
mode:
Diffstat (limited to 'ghc/GHCi/UI.hs')
-rw-r--r--ghc/GHCi/UI.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs
index 3ccd2e2678..6112428d22 100644
--- a/ghc/GHCi/UI.hs
+++ b/ghc/GHCi/UI.hs
@@ -2116,13 +2116,16 @@ exceptT = ExceptT . pure
-- | @:type@ command. See also Note [TcRnExprMode] in GHC.Tc.Module.
typeOfExpr :: GHC.GhcMonad m => String -> m ()
-typeOfExpr str = handleSourceError GHC.printException $ do
- let (mode, expr_str) = case break isSpace str of
- ("+d", rest) -> (GHC.TM_Default, dropWhile isSpace rest)
- ("+v", rest) -> (GHC.TM_NoInst, dropWhile isSpace rest)
- _ -> (GHC.TM_Inst, str)
- ty <- GHC.exprType mode expr_str
- printForUser $ sep [text expr_str, nest 2 (dcolon <+> pprTypeForUser ty)]
+typeOfExpr str = handleSourceError GHC.printException $
+ case break isSpace str of
+ ("+v", _) -> printForUser (text "`:type +v' has gone; use `:type' instead")
+ ("+d", rest) -> do_it GHC.TM_Default (dropWhile isSpace rest)
+ _ -> do_it GHC.TM_Inst str
+ where
+ do_it mode expr_str
+ = do { ty <- GHC.exprType mode expr_str
+ ; printForUser $ sep [ text expr_str
+ , nest 2 (dcolon <+> pprTypeForUser ty)] }
-----------------------------------------------------------------------------
-- | @:type-at@ command