Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/2ec32a8e1cb323b230b0c228dbee313647892bf4 >--------------------------------------------------------------- commit 2ec32a8e1cb323b230b0c228dbee313647892bf4 Author: Iavor S. Diatchki <diatc...@galois.com> Date: Thu Nov 29 17:14:48 2012 -0800 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. >--------------------------------------------------------------- compiler/main/InteractiveEval.hs | 10 ++++++---- ghc/InteractiveUI.hs | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs index 5f7d0c7..c5f35e5 100644 --- a/compiler/main/InteractiveEval.hs +++ b/compiler/main/InteractiveEval.hs @@ -890,8 +890,8 @@ moduleIsInterpreted modl = withSession $ \h -> -- are in scope (qualified or otherwise). Otherwise we list a whole lot too many! -- The exact choice of which ones to show, and which to hide, is a judgement call. -- (see Trac #1581) -getInfo :: GhcMonad m => Name -> m (Maybe (TyThing,Fixity,[ClsInst])) -getInfo name +getInfo :: GhcMonad m => Bool -> Name -> m (Maybe (TyThing,Fixity,[ClsInst])) +getInfo allInfo name = withSession $ \hsc_env -> do mb_stuff <- liftIO $ hscTcRnGetInfo hsc_env name case mb_stuff of @@ -900,8 +900,10 @@ getInfo name let rdr_env = ic_rn_gbl_env (hsc_IC hsc_env) return (Just (thing, fixity, filter (plausible rdr_env) ispecs)) where - plausible rdr_env ispec -- Dfun involving only names that are in ic_rn_glb_env - = all ok $ nameSetToList $ orphNamesOfType $ idType $ instanceDFunId ispec + plausible rdr_env ispec + -- Dfun involving only names that are in ic_rn_glb_env + = allInfo + || all ok (nameSetToList $ orphNamesOfType $ idType $ instanceDFunId ispec) where -- A name is ok if it's in the rdr_env, -- whether qualified or not ok n | n == name = True -- The one we looked for in the first place! diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs index 9c4a492..c0d5f19 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) = _______________________________________________ Cvs-ghc mailing list Cvs-ghc@haskell.org http://www.haskell.org/mailman/listinfo/cvs-ghc