diff options
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 12 | ||||
-rw-r--r-- | ghc/GHCi/UI/Info.hs | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index c04bf2d194..1e27c7a861 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -299,6 +299,8 @@ defFullHelpText = " :run function [<arguments> ...] run the function with the given arguments\n" ++ " :script <file> run the script <file>\n" ++ " :type <expr> show the type of <expr>\n" ++ + " :type +d <expr> show the type of <expr>, defaulting type variables\n" ++ + " :type +v <expr> show the type of <expr>, with its specified tyvars\n" ++ " :undef <cmd> undefine user-defined command :<cmd>\n" ++ " :!<command> run the shell command <command>\n" ++ "\n" ++ @@ -1811,12 +1813,16 @@ exceptT :: Applicative m => Either e a -> ExceptT e m a exceptT = ExceptT . pure ----------------------------------------------------------------------------- --- | @:type@ command +-- | @:type@ command. See also Note [TcRnExprMode] in TcRnDriver. typeOfExpr :: String -> InputT GHCi () typeOfExpr str = handleSourceError GHC.printException $ do - ty <- GHC.exprType str - printForUser $ sep [text str, nest 2 (dcolon <+> pprTypeForUser ty)] + 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)] ----------------------------------------------------------------------------- -- | @:type-at@ command diff --git a/ghc/GHCi/UI/Info.hs b/ghc/GHCi/UI/Info.hs index 2c44e3f8e2..ef5e9ef207 100644 --- a/ghc/GHCi/UI/Info.hs +++ b/ghc/GHCi/UI/Info.hs @@ -215,7 +215,7 @@ findType infos span0 string = do MaybeT $ pure $ M.lookup name infos case resolveType (modinfoSpans info) (spanInfoFromRealSrcSpan' span0) of - Nothing -> (,) info <$> lift (exprType string) + Nothing -> (,) info <$> lift (exprType TM_Inst string) Just ty -> return (info, ty) where -- | Try to resolve the type display from the given span. |