Commit c85cd9b2 authored by bitonic's avatar bitonic Committed by Ben Gamari
Browse files

Show only the number of modules in ghci

Reviewers: bgamari, austin, simonmar

Reviewed By: bgamari

Subscribers: mpickering, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3651
parent 88263f93
......@@ -51,7 +51,7 @@ import GHC ( LoadHowMuch(..), Target(..), TargetId(..), InteractiveImport(..),
import HsImpExp
import HsSyn
import HscTypes ( tyThingParent_maybe, handleFlagWarnings, getSafeMode, hsc_IC,
setInteractivePrintName, hsc_dflags, msObjFilePath )
setInteractivePrintName, hsc_dflags )
import Module
import Name
import Packages ( trusted, getPackageDetails, getInstalledPackageDetails,
......@@ -1721,7 +1721,7 @@ afterLoad ok retain_context = do
lift revertCAFs -- always revert CAFs on load.
lift discardTickArrays
loaded_mods <- getLoadedModules
modulesLoadedMsg ok loaded_mods
modulesLoadedMsg ok (length loaded_mods)
lift $ setContextAfterLoad retain_context loaded_mods
setContextAfterLoad :: Bool -> [GHC.ModSummary] -> GHCi ()
......@@ -1796,27 +1796,18 @@ keepPackageImports = filterM is_pkg_import
mod_name = unLoc (ideclName d)
modulesLoadedMsg :: SuccessFlag -> [GHC.ModSummary] -> InputT GHCi ()
modulesLoadedMsg ok mods = do
modulesLoadedMsg :: SuccessFlag -> Int -> InputT GHCi ()
modulesLoadedMsg ok num_mods = do
dflags <- getDynFlags
unqual <- GHC.getPrintUnqual
let mod_name mod = do
is_interpreted <- GHC.moduleIsBootOrNotObjectLinkable mod
return $ if is_interpreted
then ppr (GHC.ms_mod mod)
else ppr (GHC.ms_mod mod)
<> text " ("
<> text (normalise $ msObjFilePath mod)
<> text ")" -- fix #9887
mod_names <- mapM mod_name mods
let mod_commas
| null mods = text "none."
| otherwise = hsep (punctuate comma mod_names) <> text "."
status = case ok of
let status = case ok of
Failed -> text "Failed"
Succeeded -> text "Ok"
msg = status <> text ", modules loaded:" <+> mod_commas
num_mods_pp = if num_mods == 1
then "1 module"
else int num_mods <+> "modules"
msg = status <> text "," <+> num_mods_pp <+> "loaded."
when (verbosity dflags > 0) $
liftIO $ putStrLn $ showSDocForUser dflags unqual msg
......
[1 of 1] Compiling A ( A.hs, interpreted )
Ok, modules loaded: A.
Ok, 1 module loaded.
True
[1 of 1] Compiling A ( A.hs, interpreted )
Ok, modules loaded: A.
Ok, 1 module loaded.
False
[1 of 2] Compiling T1914B ( T1914B.hs, interpreted )
[2 of 2] Compiling T1914A ( T1914A.hs, interpreted )
Ok, modules loaded: T1914A, T1914B.
Ok, 2 modules loaded.
[2 of 2] Compiling T1914A ( T1914A.hs, interpreted )
Failed, modules loaded: T1914B.
Failed, 1 module loaded.
[2 of 2] Compiling T1914A ( T1914A.hs, interpreted )
Ok, modules loaded: T1914A, T1914B.
Ok, 2 modules loaded.
[1 of 1] Compiling T6105 ( T6105.hs, interpreted )
Ok, modules loaded: T6105.
Ok, 1 module loaded.
[1 of 1] Compiling T6105 ( T6105.hs, interpreted )
Ok, modules loaded: T6105.
Ok, 1 module loaded.
Ok, modules loaded: Ghci058 (Ghci058.o).
Ok, 1 module loaded.
'a'
Ok, modules loaded: Ghci058 (Ghci058.o).
Ok, 1 module loaded.
'b'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment