[project @ 2000-11-24 17:02:01 by simonpj]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcDeriv.lhs
index e068f8a..db21e8e 100644 (file)
@@ -26,8 +26,7 @@ import TcSimplify     ( tcSimplifyThetas )
 
 import RnBinds         ( rnMethodBinds, rnTopMonoBinds )
 import RnEnv           ( bindLocatedLocalsRn )
-import RnMonad         ( --RnNameSupply, 
-                         renameSourceCode, thenRn, mapRn, returnRn )
+import RnMonad         ( renameDerivedCode, thenRn, mapRn, returnRn )
 import HscTypes                ( DFunId, PersistentRenamerState )
 
 import BasicTypes      ( Fixity )
@@ -194,7 +193,7 @@ tcDeriving prs mod inst_env_in get_fixity tycl_decls
 
        -- Fish the "deriving"-related information out of the TcEnv
        -- and make the necessary "equations".
-    makeDerivEqns mod tycl_decls               `thenTc` \ eqns ->
+    makeDerivEqns tycl_decls           `thenTc` \ eqns ->
     if null eqns then
        returnTc ([], EmptyBinds)
     else
@@ -224,7 +223,7 @@ tcDeriving prs mod inst_env_in get_fixity tycl_decls
        -- The only tricky bit is that the extra_binds must scope over the
        -- method bindings for the instances.
        (rn_method_binds_s, rn_extra_binds)
-               = renameSourceCode dflags mod prs (
+               = renameDerivedCode dflags mod prs (
                        bindLocatedLocalsRn (ptext (SLIT("deriving"))) mbinders $ \ _ ->
                        rnTopMonoBinds extra_mbinds []          `thenRn` \ (rn_extra_binds, _) ->
                        mapRn rn_meths method_binds_s           `thenRn` \ rn_method_binds_s ->
@@ -277,9 +276,9 @@ or} has just one data constructor (e.g., tuples).
 all those.
 
 \begin{code}
-makeDerivEqns :: Module -> [RenamedTyClDecl] -> TcM [DerivEqn]
+makeDerivEqns :: [RenamedTyClDecl] -> TcM [DerivEqn]
 
-makeDerivEqns this_mod tycl_decls
+makeDerivEqns tycl_decls
   = mapTc mk_eqn derive_these          `thenTc` \ maybe_eqns ->
     returnTc (catMaybes maybe_eqns)
   where
@@ -288,7 +287,7 @@ makeDerivEqns this_mod tycl_decls
        -- Find the (Class,TyCon) pairs that must be `derived'
        -- NB: only source-language decls have deriving, no imported ones do
     derive_these = [ (clas,tycon) 
-                  | TyData _ _ tycon _ _ _ (Just classes) _ _ _ <- tycl_decls,
+                  | TyData {tcdName = tycon, tcdDerivs = Just classes} <- tycl_decls,
                     clas <- nub classes ]
 
     ------------------------------------------------------------------
@@ -324,7 +323,7 @@ makeDerivEqns this_mod tycl_decls
        case chk_out clas tycon of
           Just err ->  addErrTc err                            `thenNF_Tc_` 
                        returnNF_Tc Nothing
-          Nothing  ->  newDFunName this_mod clas [ty] locn `thenNF_Tc` \ dfun_name ->
+          Nothing  ->  newDFunName clas [ty] locn `thenNF_Tc` \ dfun_name ->
                        returnNF_Tc (Just (dfun_name, clas, tycon, tyvars, constraints))