import GHC ( Session, verbosity, dopt, DynFlag(..),
mkModule, pprModule, Type, Module, SuccessFlag(..),
TyThing(..), Name, LoadHowMuch(..),
- GhcException(..), showGhcException )
+ GhcException(..), showGhcException,
+ CheckedModule(..) )
import Outputable
-- following all needed for :info... ToDo: remove
import FunDeps ( pprFundeps )
import SrcLoc ( SrcLoc, pprDefnLoc )
import OccName ( OccName, parenSymOcc, occNameUserString )
-import BasicTypes ( StrictnessMark(..), defaultFixity, failed )
+import BasicTypes ( StrictnessMark(..), defaultFixity, failed, successIf )
-- Other random utilities
import Panic ( panic, installSignalHandlers )
import Linker ( showLinkerState )
import Util ( removeSpaces, handle, global, toArgs,
looksLikeModuleName, prefixMatch )
+import ErrUtils ( printErrorsAndWarnings )
#ifndef mingw32_HOST_OS
import Util ( handle )
("load", keepGoingPaths loadModule_),
("module", keepGoing setContext),
("reload", keepGoing reloadModule),
+ ("check", keepGoing checkModule),
("set", keepGoing setCmd),
("show", keepGoing showCmd),
("type", keepGoing typeOfExpr),
afterLoad ok session
return ok
+checkModule :: String -> GHCi ()
+checkModule m = do
+ let modl = mkModule m
+ session <- getSession
+ result <- io (GHC.checkModule session modl printErrorsAndWarnings)
+ case result of
+ Nothing -> io $ putStrLn "Nothing"
+ Just r -> io $ putStrLn (showSDoc (
+ case checkedModuleInfo r of
+ Just cm | Just scope <- GHC.modInfoTopLevelScope cm ->
+ let
+ (local,global) = partition ((== modl) . GHC.nameModule) scope
+ in
+ (text "global names: " <+> ppr global) $$
+ text "local names: " <+> ppr local))
+ _ -> empty
+ afterLoad (successIf (isJust result)) session
reloadModule :: String -> GHCi ()
reloadModule "" = do