+\begin{code}
+-- | parse a file, returning the abstract syntax
+parseFile :: HscEnv -> ModSummary -> IO (Maybe (Located (HsModule RdrName)))
+parseFile hsc_env mod_summary
+ = do
+ maybe_parsed <- myParseModule dflags hspp_file hspp_buf
+ case maybe_parsed of
+ Left err
+ -> do printBagOfErrors dflags (unitBag err)
+ return Nothing
+ Right rdr_module
+ -> return (Just 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 :: HscEnv -> ModSummary -> Located (HsModule RdrName)
+ -> IO (Maybe TcGblEnv)
+typecheckModule hsc_env mod_summary rdr_module
+ = do
+ (tc_msgs, maybe_tc_result)
+ <- {-# SCC "Typecheck-Rename" #-}
+ tcRnModule hsc_env (ms_hsc_src mod_summary) False rdr_module
+ printErrorsAndWarnings dflags tc_msgs
+ return maybe_tc_result
+ where
+ dflags = hsc_dflags hsc_env
+
+type RenamedStuff =
+ (Maybe (HsGroup Name, [LImportDecl Name], Maybe [LIE Name],
+ Maybe (HsDoc Name), HaddockModInfo Name))
+
+-- | Rename and typecheck a module, additinoally returning the renamed syntax
+typecheckRenameModule :: HscEnv -> ModSummary -> Located (HsModule RdrName)
+ -> IO (Maybe (TcGblEnv, RenamedStuff))
+typecheckRenameModule hsc_env mod_summary rdr_module
+ = do
+ (tc_msgs, maybe_tc_result)
+ <- {-# SCC "Typecheck-Rename" #-}
+ tcRnModule hsc_env (ms_hsc_src mod_summary) True rdr_module
+ printErrorsAndWarnings dflags tc_msgs
+ case maybe_tc_result of
+ Nothing -> return Nothing
+ Just tc_result -> do
+ 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 (Just (tc_result, rn_info))
+ where
+ dflags = hsc_dflags hsc_env
+
+-- | Convert a typechecked module to Core
+deSugarModule :: HscEnv -> ModSummary -> TcGblEnv -> IO (Maybe ModGuts)
+deSugarModule hsc_env mod_summary tc_result
+ = 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}
+