-- a list of the bound values, coerced to ().
tcRnStmt hsc_env ictxt rdr_stmt
- = initTc hsc_env iNTERACTIVE $
+ = initTcPrintErrors hsc_env iNTERACTIVE $
setInteractiveContext ictxt $ do {
-- Rename; use CmdLineMode because tcRnStmt is only used interactively
-> LHsExpr RdrName
-> IO (Maybe Type)
tcRnExpr hsc_env ictxt rdr_expr
- = initTc hsc_env iNTERACTIVE $
+ = initTcPrintErrors hsc_env iNTERACTIVE $
setInteractiveContext ictxt $ do {
(rn_expr, fvs) <- rnLExpr rdr_expr ;
-- *and* as a type or class constructor;
-- hence the call to dataTcOccs, and we return up to two results
tcRnThing hsc_env ictxt rdr_name
- = initTc hsc_env iNTERACTIVE $
+ = initTcPrintErrors hsc_env iNTERACTIVE $
setInteractiveContext ictxt $ do {
-- If the identifier is a constructor (begins with an
-> IO GlobalRdrEnv
mkExportEnv hsc_env exports
- = do { mb_envs <- initTc hsc_env iNTERACTIVE $
+ = do { mb_envs <- initTcPrintErrors hsc_env iNTERACTIVE $
mappM getModuleExports exports
; case mb_envs of
Just envs -> return (foldr plusGlobalRdrEnv emptyGlobalRdrEnv envs)
-> IO (Maybe [IfaceDecl])
getModuleContents hsc_env ictxt mod exports_only
- = initTc hsc_env iNTERACTIVE (get_mod_contents exports_only)
+ = initTcPrintErrors hsc_env iNTERACTIVE (get_mod_contents exports_only)
where
get_mod_contents exports_only
| not exports_only -- We want the whole top-level type env
-- list, and there are no bindings in M, we don't bleat
-- "unknown module M".
+initTcPrintErrors
+ :: HscEnv
+ -> Module
+ -> TcM r
+ -> IO (Maybe r)
+initTcPrintErrors env mod todo = do
+ (msgs, res) <- initTc env mod todo
+ printErrorsAndWarnings msgs
+ return res
+
mkImpInstEnv :: HscEnv -> InstEnv
-- At the moment we (wrongly) build an instance environment from all the
-- home-package modules we have already compiled.