[project @ 2002-11-28 17:17:41 by simonpj]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcRnDriver.lhs
index d251db6..d6ea564 100644 (file)
@@ -17,7 +17,7 @@ module TcRnDriver (
 
 #ifdef GHCI
 import {-# SOURCE #-} TcSplice ( tcSpliceDecls )
-import               DsMeta   ( qTyConName )
+import               DsMeta   ( templateHaskellNames )
 #endif
 
 import CmdLineOpts     ( DynFlag(..), opt_PprStyle_Debug, dopt )
@@ -486,9 +486,16 @@ tcRnThing hsc_env pcs ictxt rdr_name
        do { addMessages (head msgs_s) ; failM }
     else do {
 
-    mapM_ addMessages msgs_s ; -- Add deprecation warnings
-    mapM tcLookupGlobal names  -- and lookup up the entities
-    }}
+       -- Add deprecation warnings
+    mapM_ addMessages msgs_s ; 
+
+       -- Slurp in the supporting declarations
+    tcg_env <- importSupportingDecls (mkFVs names) ;
+    setGblEnv tcg_env $ do {
+
+       -- And lookup up the entities
+    mapM tcLookupGlobal names
+    }}}
 \end{code}
 
 
@@ -609,7 +616,7 @@ tcRnSrcDecls ds
        (rn_splice_expr, fvs) <- initRn SourceMode $
                                 addSrcLoc splice_loc $
                                 rnExpr splice_expr ;
-       tcg_env <- importSupportingDecls (fvs `addOneFV` qTyConName) ;
+       tcg_env <- importSupportingDecls (fvs `plusFV` templateHaskellNames) ;
        setGblEnv tcg_env $ do {
 
        -- Execute the splice
@@ -695,7 +702,7 @@ tcTopSrcDecls rn_decls
        -- in this module, which is why the knot is so big
 
                        -- Do the main work
-       ((tcg_env, binds, rules, fords), lie) <- getLIE (
+       ((tcg_env, lcl_env, binds, rules, fords), lie) <- getLIE (
                tc_src_decls unf_env rn_decls
            ) ;
 
@@ -706,8 +713,12 @@ tcTopSrcDecls rn_decls
             -- type.  (Usually, ambiguous type variables are resolved
             -- during the generalisation step.)
         traceTc (text "Tc8") ;
-       inst_binds <- setGblEnv tcg_env (tcSimplifyTop lie) ;
+       inst_binds <- setGblEnv tcg_env $
+                     setLclTypeEnv lcl_env $
+                     tcSimplifyTop lie ;
                -- The setGblEnv exposes the instances to tcSimplifyTop
+               -- The steLclTypeEnv exposes the local Ids, so that
+               -- we get better error messages (monomorphism restriction)
 
            -- Backsubstitution.  This must be done last.
            -- Even tcSimplifyTop may do some unification.
@@ -792,7 +803,7 @@ tc_src_decls unf_env
                          cls_dm_binds   `AndMonoBinds`
                          foe_binds } ;
 
-       return (tcg_env, all_binds, src_rules, foe_decls)
+       return (tcg_env, lcl_env, all_binds, src_rules, foe_decls)
      }}}}}}}}}
 \end{code}