Commit 850490af authored by nfrisby's avatar nfrisby

factor 'tcRnModuleTcRnM' out of 'tcRnModule' and export it

'tcRnModuleTcRnM' builds the TcRnM monad computation that is the bulk of
'tcRnModule'

This commit makes it simpler for courageous Core plugins to invoke the
typechecker. In particular, they no longer need to copy-and-paste what is now
the body of 'tcRnModuleTcRnM'. The key change is that the 'tcRnModuleTcRnM'
computation can be run with (a hypothetical) 'initTcFromCoreM' instead of
'initTc'.
parent 9039108b
...@@ -16,7 +16,7 @@ module TcRnDriver ( ...@@ -16,7 +16,7 @@ module TcRnDriver (
#endif #endif
tcRnLookupName, tcRnLookupName,
tcRnGetInfo, tcRnGetInfo,
tcRnModule, tcRnModule, tcRnModuleTcRnM,
tcTopSrcDecls, tcTopSrcDecls,
tcRnExtCore tcRnExtCore
) where ) where
...@@ -118,19 +118,12 @@ tcRnModule :: HscEnv ...@@ -118,19 +118,12 @@ tcRnModule :: HscEnv
-> IO (Messages, Maybe TcGblEnv) -> IO (Messages, Maybe TcGblEnv)
tcRnModule hsc_env hsc_src save_rn_syntax tcRnModule hsc_env hsc_src save_rn_syntax
HsParsedModule { parsedModule@HsParsedModule {hpm_module=L loc this_module}
hpm_module =
(L loc (HsModule maybe_mod export_ies
import_decls local_decls mod_deprec
maybe_doc_hdr)),
hpm_src_files =
src_files
}
= do { showPass (hsc_dflags hsc_env) "Renamer/typechecker" ; = do { showPass (hsc_dflags hsc_env) "Renamer/typechecker" ;
let { this_pkg = thisPackage (hsc_dflags hsc_env) ; let { this_pkg = thisPackage (hsc_dflags hsc_env) ;
(this_mod, prel_imp_loc) pair@(this_mod,_)
= case maybe_mod of = case hsmodName this_module of
Nothing -- 'module M where' is omitted Nothing -- 'module M where' is omitted
-> (mAIN, srcLocSpan (srcSpanStart loc)) -> (mAIN, srcLocSpan (srcSpanStart loc))
...@@ -138,6 +131,23 @@ tcRnModule hsc_env hsc_src save_rn_syntax ...@@ -138,6 +131,23 @@ tcRnModule hsc_env hsc_src save_rn_syntax
-> (mkModule this_pkg mod, mod_loc) } ; -> (mkModule this_pkg mod, mod_loc) } ;
initTc hsc_env hsc_src save_rn_syntax this_mod $ initTc hsc_env hsc_src save_rn_syntax this_mod $
tcRnModuleTcRnM hsc_env hsc_src parsedModule pair }
tcRnModuleTcRnM :: HscEnv
-> HscSource
-> HsParsedModule
-> (Module, SrcSpan)
-> TcRn TcGblEnv
tcRnModuleTcRnM hsc_env hsc_src
(HsParsedModule {
hpm_module =
(L loc (HsModule maybe_mod export_ies
import_decls local_decls mod_deprec
maybe_doc_hdr)),
hpm_src_files =
src_files
})
(this_mod, prel_imp_loc) =
setSrcSpan loc $ setSrcSpan loc $
do { -- Deal with imports; first add implicit prelude do { -- Deal with imports; first add implicit prelude
implicit_prelude <- xoptM Opt_ImplicitPrelude; implicit_prelude <- xoptM Opt_ImplicitPrelude;
...@@ -210,7 +220,7 @@ tcRnModule hsc_env hsc_src save_rn_syntax ...@@ -210,7 +220,7 @@ tcRnModule hsc_env hsc_src save_rn_syntax
-- Dump output and return -- Dump output and return
tcDump tcg_env ; tcDump tcg_env ;
return tcg_env return tcg_env
}}}} }}}
implicitPreludeWarn :: SDoc implicitPreludeWarn :: SDoc
......
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