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 )
-- 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
-- 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 ->
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
-- 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 ]
------------------------------------------------------------------
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))