Commit 41051dd8 authored by lukyanov's avatar lukyanov Committed by Ben Gamari

ghci: add message when reusing compiled code #9887

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D1991

GHC Trac Issues: #9887
parent 4d791b4f
......@@ -232,7 +232,7 @@ We can compile ``D``, then load the whole program, like this:
Compiling B ( B.hs, interpreted )
Compiling C ( C.hs, interpreted )
Compiling A ( A.hs, interpreted )
Ok, modules loaded: A, B, C, D.
Ok, modules loaded: A, B, C, D (D.o).
*Main>
In the messages from the compiler, we see that there is no line for
......@@ -304,7 +304,7 @@ picked up by :ghci-cmd:`:reload`, only :ghci-cmd:`:load`:
*Main> :load A
Compiling B ( B.hs, interpreted )
Compiling A ( A.hs, interpreted )
Ok, modules loaded: A, B, C, D.
Ok, modules loaded: A, B, C (C.o), D (D.o).
The automatic loading of object files can sometimes lead to confusion,
because non-exported top-level definitions of a module are only
......
......@@ -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 )
setInteractivePrintName, hsc_dflags, msObjFilePath )
import Module
import Name
import Packages ( trusted, getPackageDetails, listVisibleModuleNames, pprFlag )
......@@ -1569,10 +1569,9 @@ afterLoad :: SuccessFlag
afterLoad ok retain_context = do
lift revertCAFs -- always revert CAFs on load.
lift discardTickArrays
loaded_mod_summaries <- getLoadedModules
let loaded_mods = map GHC.ms_mod loaded_mod_summaries
loaded_mods <- getLoadedModules
modulesLoadedMsg ok loaded_mods
lift $ setContextAfterLoad retain_context loaded_mod_summaries
lift $ setContextAfterLoad retain_context loaded_mods
setContextAfterLoad :: Bool -> [GHC.ModSummary] -> GHCi ()
setContextAfterLoad keep_ctxt [] = do
......@@ -1646,14 +1645,22 @@ keepPackageImports = filterM is_pkg_import
mod_name = unLoc (ideclName d)
modulesLoadedMsg :: SuccessFlag -> [Module] -> InputT GHCi ()
modulesLoadedMsg :: SuccessFlag -> [GHC.ModSummary] -> InputT GHCi ()
modulesLoadedMsg ok mods = do
dflags <- getDynFlags
unqual <- GHC.getPrintUnqual
let mod_name mod = do
is_interpreted <- GHC.isModuleInterpreted 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 (map ppr mods)) <> text "."
| otherwise = hsep (punctuate comma mod_names) <> text "."
status = case ok of
Failed -> text "Failed"
Succeeded -> text "Ok"
......
Ok, modules loaded: Ghci058.
Ok, modules loaded: Ghci058 (Ghci058.o).
'a'
Ok, modules loaded: Ghci058.
Ok, modules loaded: Ghci058 (Ghci058.o).
'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