- zonkBinds record_binds `thenNF_Tc` \ record_binds' ->
- zonkBinds val_binds `thenNF_Tc` \ val_binds' ->
- zonkBinds inst_binds `thenNF_Tc` \ inst_binds' ->
- zonkBinds cls_binds `thenNF_Tc` \ cls_binds' ->
- mapNF_Tc zonkInst const_insts `thenNF_Tc` \ const_insts' ->
- mapNF_Tc (zonkId.TcId) exported_ids `thenNF_Tc` \ exported_ids' ->
+ --
+ -- More horrible still, we have to do it in a careful order, so that
+ -- all the TcIds are in scope when we come across them.
+ --
+ -- These bindings ought really to be bundled together in a huge
+ -- recursive group, but HsSyn doesn't have recursion among Binds, only
+ -- among MonoBinds. Sigh again.
+ zonkDictBinds nullTyVarEnv nullIdEnv const_insts `thenNF_Tc` \ (const_insts', ve1) ->
+ zonkBinds nullTyVarEnv ve1 val_binds `thenNF_Tc` \ (val_binds', ve2) ->
+
+ zonkBinds nullTyVarEnv ve2 data_binds `thenNF_Tc` \ (data_binds', _) ->
+ zonkBinds nullTyVarEnv ve2 inst_binds `thenNF_Tc` \ (inst_binds', _) ->
+ zonkBinds nullTyVarEnv ve2 cls_binds `thenNF_Tc` \ (cls_binds', _) ->
+
+ let
+ localids = getEnv_LocalIds final_env
+ tycons = getEnv_TyCons final_env
+ classes = getEnv_Classes final_env
+
+ local_tycons = [ tc | tc <- tycons, isLocallyDefined tc && isDataTyCon tc ]
+ local_classes = filter isLocallyDefined classes
+ exported_ids' = filter isExported (eltsUFM ve2)
+ in