Ticket #2986: ghci-info-no-instances.patch
| File ghci-info-no-instances.patch, 2.5 KB (added by Remi, 4 years ago) |
|---|
-
compiler/ghci/InteractiveUI.hs
old new 211 211 " :edit edit last module\n" ++ 212 212 " :etags [<file>] create tags file for Emacs (default: \"TAGS\")\n" ++ 213 213 " :help, :? display this list of commands\n" ++ 214 " :info [ <name> ...]display information about the given names\n" ++214 " :info [-][<name> ...] display information about the given names\n" ++ 215 215 " :kind <type> show the kind of <type>\n" ++ 216 216 " :load [*]<module> ... load module(s) and their dependents\n" ++ 217 217 " :main [<arguments> ...] run the main function with the given arguments\n" ++ … … 876 876 help _ = io (putStr helpText) 877 877 878 878 info :: String -> GHCi () 879 info "" = ghcError (CmdLineError "syntax: ':i <thing-you-want-info-about>'") 879 info "" = ghcError (CmdLineError "syntax: ':i [-]<thing-you-want-info-about>'") 880 info "-"= ghcError (CmdLineError "syntax: ':i [-]<thing-you-want-info-about>'") 880 881 info s = handleSourceError GHC.printExceptionAndWarnings $ do 881 { let names = words s 882 ; dflags <- getDynFlags 882 { dflags <- getDynFlags 883 883 ; let pefas = dopt Opt_PrintExplicitForalls dflags 884 884 ; mapM_ (infoThing pefas) names } 885 885 where 886 (wantInstances, names) = case s of 887 '-' : s'-> (False, words s') 888 _ -> (True, words s) 886 889 infoThing pefas str = do 887 890 names <- GHC.parseName str 888 891 mb_stuffs <- mapM GHC.getInfo names … … 891 894 liftIO $ 892 895 putStrLn (showSDocForUser unqual $ 893 896 vcat (intersperse (text "") $ 894 map (pprInfo pefas ) filtered))897 map (pprInfo pefas wantInstances) filtered)) 895 898 896 899 -- Filter out names whose parent is also there Good 897 900 -- example is '[]', which is both a type and data … … 902 905 where 903 906 implicits = mkNameSet [getName t | x <- xs, t <- implicitTyThings (get_thing x)] 904 907 905 pprInfo :: PrintExplicitForalls -> (TyThing, Fixity, [GHC.Instance]) -> SDoc906 pprInfo pefas (thing, fixity, insts)908 pprInfo :: PrintExplicitForalls -> Bool -> (TyThing, Fixity, [GHC.Instance]) -> SDoc 909 pprInfo pefas wantInstances (thing, fixity, insts) 907 910 = pprTyThingInContextLoc pefas thing 908 911 $$ show_fixity fixity 909 $$ vcat (map GHC.pprInstance insts)912 $$ if wantInstances then vcat (map GHC.pprInstance insts) else empty 910 913 where 911 914 show_fixity fix 912 915 | fix == GHC.defaultFixity = empty
