diff options
author | Iavor S. Diatchki <diatchki@galois.com> | 2012-11-29 17:14:48 -0800 |
---|---|---|
committer | Iavor S. Diatchki <diatchki@galois.com> | 2012-11-29 17:21:04 -0800 |
commit | 2ec32a8e1cb323b230b0c228dbee313647892bf4 (patch) | |
tree | 05218eb0b833f7dfca576d403737550d0f9ae03e /ghc | |
parent | 77ef6ca06d401eda2aeb51d22d5ce033db667161 (diff) | |
download | haskell-2ec32a8e1cb323b230b0c228dbee313647892bf4.tar.gz |
Add ":info!" to GHCi. This shows all instances without filtering first.
The default behavior of :info is to show only those instances of
for a type, where all relevant type constructor names are in scope.
This keeps down the number of instances shown to the user.
In some cases, it is nice to be able to see all instances for a type.
This patch implements this with the :info! command.
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/InteractiveUI.hs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs index 9c4a492b6d..c0d5f19233 100644 --- a/ghc/InteractiveUI.hs +++ b/ghc/InteractiveUI.hs @@ -155,7 +155,8 @@ ghciCommands = [ ("forward", keepGoing forwardCmd, noCompletion), ("help", keepGoing help, noCompletion), ("history", keepGoing historyCmd, noCompletion), - ("info", keepGoing' info, completeIdentifier), + ("info", keepGoing' (info False), completeIdentifier), + ("info!", keepGoing' (info True), completeIdentifier), ("issafe", keepGoing' isSafeCmd, completeModule), ("kind", keepGoing' (kindOfType False), completeIdentifier), ("kind!", keepGoing' (kindOfType True), completeIdentifier), @@ -237,7 +238,8 @@ defFullHelpText = " :edit edit last module\n" ++ " :etags [<file>] create tags file for Emacs (default: \"TAGS\")\n" ++ " :help, :? display this list of commands\n" ++ - " :info [<name> ...] display information about the given names\n" ++ + " :info[!] [<name> ...] display information about the given names\n" ++ + " (!: do not filter instances)\n" ++ " :issafe [<mod>] display safe haskell information of module <mod>\n" ++ " :kind <type> show the kind of <type>\n" ++ " :load [*]<module> ... load module(s) and their dependents\n" ++ @@ -1006,20 +1008,20 @@ help _ = do ----------------------------------------------------------------------------- -- :info -info :: String -> InputT GHCi () -info "" = throwGhcException (CmdLineError "syntax: ':i <thing-you-want-info-about>'") -info s = handleSourceError GHC.printException $ do +info :: Bool -> String -> InputT GHCi () +info _ "" = throwGhcException (CmdLineError "syntax: ':i <thing-you-want-info-about>'") +info allInfo s = handleSourceError GHC.printException $ do unqual <- GHC.getPrintUnqual dflags <- getDynFlags - sdocs <- mapM infoThing (words s) + sdocs <- mapM (infoThing allInfo) (words s) mapM_ (liftIO . putStrLn . showSDocForUser dflags unqual) sdocs -infoThing :: GHC.GhcMonad m => String -> m SDoc -infoThing str = do +infoThing :: GHC.GhcMonad m => Bool -> String -> m SDoc +infoThing allInfo str = do dflags <- getDynFlags let pefas = gopt Opt_PrintExplicitForalls dflags names <- GHC.parseName str - mb_stuffs <- mapM GHC.getInfo names + mb_stuffs <- mapM (GHC.getInfo allInfo) names let filtered = filterOutChildren (\(t,_f,_i) -> t) (catMaybes mb_stuffs) return $ vcat (intersperse (text "") $ map (pprInfo pefas) filtered) @@ -2185,7 +2187,7 @@ showBindings = do makeDoc tt = do dflags <- getDynFlags let pefas = gopt Opt_PrintExplicitForalls dflags - mb_stuff <- GHC.getInfo (getName tt) + mb_stuff <- GHC.getInfo False (getName tt) return $ maybe (text "") (pprTT pefas) mb_stuff pprTT :: PrintExplicitForalls -> (TyThing, Fixity, [GHC.ClsInst]) -> SDoc pprTT pefas (thing, fixity, _insts) = |