[project @ 2003-11-06 17:09:50 by simonpj]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcRnDriver.lhs
index 9a9e98b..7fbbc32 100644 (file)
@@ -10,7 +10,7 @@ module TcRnDriver (
 #endif
        tcRnModule, 
        tcTopSrcDecls,
-       tcRnIface, tcRnExtCore
+       tcRnExtCore
     ) where
 
 #include "HsVersions.h"
@@ -42,7 +42,7 @@ import TcEnv          ( tcExtendGlobalValEnv, tcLookupGlobal )
 import TcRules         ( tcRules )
 import TcForeign       ( tcForeignImports, tcForeignExports )
 import TcInstDcls      ( tcInstDecls1, tcInstDecls2 )
-import TcIface         ( typecheckIface, tcExtCoreBindings )
+import TcIface         ( tcExtCoreBindings )
 import TcSimplify      ( tcSimplifyTop )
 import TcTyClsDecls    ( tcTyAndClassDecls )
 import LoadIface       ( loadOrphanModules )
@@ -199,24 +199,6 @@ tcRnModule hsc_env
 \end{code}
 
 
-%*********************************************************
-%*                                                      *
-\subsection{Closing up the interface decls}
-%*                                                      *
-%*********************************************************
-
-Suppose we discover we don't need to recompile.   Then we start from the
-IfaceDecls in the ModIface, and fluff them up by sucking in all the decls they need.
-
-\begin{code}
-tcRnIface :: HscEnv
-         -> ModIface   -- Get the decls from here
-         -> IO ModDetails
-tcRnIface hsc_env iface
-  = initIfaceTc hsc_env iface (typecheckIface iface)
-\end{code}
-
-
 %************************************************************************
 %*                                                                     *
                The interactive interface 
@@ -655,6 +637,8 @@ tc_rn_src_decls ds
        -- Rename the splice expression, and get its supporting decls
        (rn_splice_expr, splice_fvs) <- addSrcLoc splice_loc $
                                        rnExpr splice_expr ;
+       failIfErrsM ;   -- Don't typecheck if renaming failed
+
        -- Execute the splice
        spliced_decls <- tcSpliceDecls rn_splice_expr ;
 
@@ -704,6 +688,7 @@ rnTopSrcDecls group
                                 tcg_imports = imports `plusImportAvails` tcg_imports gbl }) 
                  $ do {
 
+       traceRn (ptext SLIT("rnTopSrcDecls") <+> ppr rdr_env) ;
        failIfErrsM ;   -- No point in continuing if (say) we have duplicate declarations
 
                -- Rename the source decls
@@ -804,12 +789,15 @@ tcTopSrcDecls
 \begin{code}
 #ifdef GHCI
 mkExportEnv :: HscEnv -> [ModuleName]  -- Expose these modules' exports only
-           -> IO (Maybe GlobalRdrEnv)
+           -> IO GlobalRdrEnv
 
 mkExportEnv hsc_env exports
-  = initTc hsc_env iNTERACTIVE $ do {
-    export_envs <- mappM getModuleExports exports ;
-    returnM (foldr plusGlobalRdrEnv emptyGlobalRdrEnv export_envs)
+  = do { mb_envs <- initTc hsc_env iNTERACTIVE $
+                    mappM getModuleExports exports 
+       ; case mb_envs of
+            Just envs -> return (foldr plusGlobalRdrEnv emptyGlobalRdrEnv envs)
+            Nothing   -> return emptyGlobalRdrEnv
+                            -- Some error; initTc will have printed it
     }
 
 getModuleExports :: ModuleName -> TcM GlobalRdrEnv
@@ -905,7 +893,7 @@ checkMain
         let { main_mod = case mb_main_mod of {
                                Just mod -> mkModuleName mod ;
                                Nothing  -> mAIN_Name } ;
-               main_fn  = case mb_main_fn of {
+              main_fn  = case mb_main_fn of {
                                Just fn -> mkRdrUnqual (mkVarOcc (mkFastString fn)) ;
                                Nothing -> main_RDR_Unqual } } ;