import HsSyn ( emptyLHsBinds )
import HscTypes ( HscEnv(..), ModGuts(..), ModIface(..),
- TyThing, TypeEnv, emptyTypeEnv,
+ TyThing, TypeEnv, emptyTypeEnv, HscSource(..), isHsBoot,
ExternalPackageState(..), HomePackageTable,
- Deprecs(..), FixityEnv, FixItem,
+ Deprecs(..), FixityEnv, FixItem,
GhciMode, lookupType, unQualInScope )
import Module ( Module, unitModuleEnv )
import RdrName ( GlobalRdrEnv, emptyGlobalRdrEnv,
\begin{code}
initTc :: HscEnv
+ -> HscSource
-> Module
-> TcM r
-> IO (Messages, Maybe r)
-- Nothing => error thrown by the thing inside
-- (error messages should have been printed already)
-initTc hsc_env mod do_this
+initTc hsc_env hsc_src mod do_this
= do { errs_var <- newIORef (emptyBag, emptyBag) ;
tvs_var <- newIORef emptyVarSet ;
type_env_var <- newIORef emptyNameEnv ;
let {
gbl_env = TcGblEnv {
tcg_mod = mod,
+ tcg_src = hsc_src,
tcg_rdr_env = emptyGlobalRdrEnv,
tcg_fix_env = emptyNameEnv,
tcg_default = Nothing,
-- list, and there are no bindings in M, we don't bleat
-- "unknown module M".
-initTcPrintErrors
+initTcPrintErrors -- Used from the interactive loop only
:: HscEnv
-> Module
-> TcM r
-> IO (Maybe r)
initTcPrintErrors env mod todo = do
- (msgs, res) <- initTc env mod todo
+ (msgs, res) <- initTc env HsSrcFile mod todo
printErrorsAndWarnings msgs
return res
getModule :: TcRn Module
getModule = do { env <- getGblEnv; return (tcg_mod env) }
+tcIsHsBoot :: TcRn Bool
+tcIsHsBoot = do { env <- getGblEnv; return (isHsBoot (tcg_src env)) }
+
getGlobalRdrEnv :: TcRn GlobalRdrEnv
getGlobalRdrEnv = do { env <- getGblEnv; return (tcg_rdr_env env) }