+\begin{code}
+-- | parse a file, returning the abstract syntax
+parseFile :: GhcMonad m => HscEnv -> ModSummary -> m (Located (HsModule RdrName))
+parseFile hsc_env mod_summary = do
+ maybe_parsed <- liftIO $ myParseModule dflags hspp_file hspp_buf
+ case maybe_parsed of
+ Left err -> do throw (mkSrcErr (unitBag err))
+ Right rdr_module
+ -> return rdr_module
+ where
+ dflags = hsc_dflags hsc_env
+ hspp_file = ms_hspp_file mod_summary
+ hspp_buf = ms_hspp_buf mod_summary
+
+-- | Rename and typecheck a module
+typecheckModule' :: GhcMonad m =>
+ HscEnv -> ModSummary -> Located (HsModule RdrName)
+ -> m TcGblEnv
+typecheckModule' hsc_env mod_summary rdr_module = do
+ r <- {-# SCC "Typecheck-Rename" #-}
+ ioMsgMaybe $ tcRnModule hsc_env (ms_hsc_src mod_summary) False rdr_module
+ return r
+
+-- XXX: should this really be a Maybe X? Check under which circumstances this
+-- can become a Nothing and decide whether this should instead throw an
+-- exception/signal an error.
+type RenamedStuff =
+ (Maybe (HsGroup Name, [LImportDecl Name], Maybe [LIE Name],
+ Maybe (HsDoc Name), HaddockModInfo Name))
+
+-- | Rename and typecheck a module, additionally returning the renamed syntax
+typecheckRenameModule
+ :: GhcMonad m =>
+ HscEnv -> ModSummary -> Located (HsModule RdrName)
+ -> m (TcGblEnv, RenamedStuff)
+typecheckRenameModule hsc_env mod_summary rdr_module = do
+ tc_result
+ <- {-# SCC "Typecheck-Rename" #-}
+ ioMsgMaybe $ tcRnModule hsc_env (ms_hsc_src mod_summary) True rdr_module
+
+ let rn_info = do decl <- tcg_rn_decls tc_result
+ imports <- tcg_rn_imports tc_result
+ let exports = tcg_rn_exports tc_result
+ let doc = tcg_doc tc_result
+ let hmi = tcg_hmi tc_result
+ return (decl,imports,exports,doc,hmi)
+
+ return (tc_result, rn_info)
+
+-- | Convert a typechecked module to Core
+deSugarModule :: GhcMonad m => HscEnv -> ModSummary -> TcGblEnv -> m ModGuts
+deSugarModule hsc_env mod_summary tc_result = do
+ ioMsgMaybe $ deSugar hsc_env (ms_location mod_summary) tc_result
+
+-- | Make a 'ModIface' from the results of typechecking. Used when
+-- not optimising, and the interface doesn't need to contain any
+-- unfoldings or other cross-module optimisation info.
+-- ToDo: the old interface is only needed to get the version numbers,
+-- we should use fingerprint versions instead.
+makeSimpleIface :: HscEnv -> Maybe ModIface -> TcGblEnv -> ModDetails
+ -> IO (ModIface,Bool)
+makeSimpleIface hsc_env maybe_old_iface tc_result details = do
+ mkIfaceTc hsc_env (fmap mi_iface_hash maybe_old_iface) details tc_result
+
+-- | Make a 'ModDetails' from the results of typechecking. Used when
+-- typechecking only, as opposed to full compilation.
+makeSimpleDetails :: HscEnv -> TcGblEnv -> IO ModDetails
+makeSimpleDetails hsc_env tc_result = mkBootModDetailsTc hsc_env tc_result
+
+-- deSugarModule :: HscEnv -> TcGblEnv -> IO Core
+\end{code}
+