-mkImplicitDataBinds :: [TyCon] -> TcM s ([Id], TcMonoBinds)
-mkImplicitDataBinds [] = returnTc ([], EmptyMonoBinds)
-mkImplicitDataBinds (tycon : tycons)
- | isSynTyCon tycon = mkImplicitDataBinds tycons
- | otherwise = mkImplicitDataBinds_one tycon `thenTc` \ (ids1, b1) ->
- mkImplicitDataBinds tycons `thenTc` \ (ids2, b2) ->
- returnTc (ids1++ids2, b1 `AndMonoBinds` b2)
-
-mkImplicitDataBinds_one tycon
- = mapTc (mkRecordSelector tycon) groups `thenTc` \ sel_ids ->
- let
- unf_ids = sel_ids ++ data_con_wrapper_ids
- all_ids = map dataConId data_cons ++ unf_ids
-
- -- For the locally-defined things
- -- we need to turn the unfoldings inside the selector Ids into bindings,
- -- and build bindigns for the constructor wrappers
- binds | isLocallyDefined tycon = idsToMonoBinds unf_ids
- | otherwise = EmptyMonoBinds
- in
- returnTc (all_ids, binds)
+tcRecordSelectors is_rec unf_env tycon data_cons
+ -- Omit the check that the fields have consistent types if
+ -- the group is recursive; TcTyClsDecls.tcGroup will repeat
+ -- with NonRecursive once we have tied the knot
+ | isRec is_rec = returnTc sel_ids
+ | otherwise = mapTc check groups `thenTc_`
+ returnTc sel_ids