- rnConDetails name locn details `thenRn` \ new_details ->
- rnContext cxt `thenRn` \ new_context ->
- returnRn (ConDecl new_name new_context new_details locn)
-
-rnConDetails con locn (VanillaCon tys)
- = mapRn rnBangTy tys `thenRn` \ new_tys ->
- returnRn (VanillaCon new_tys)
-
-rnConDetails con locn (InfixCon ty1 ty2)
- = rnBangTy ty1 `thenRn` \ new_ty1 ->
- rnBangTy ty2 `thenRn` \ new_ty2 ->
- returnRn (InfixCon new_ty1 new_ty2)
-
-rnConDetails con locn (NewCon ty)
- = rnHsType ty `thenRn` \ new_ty ->
- returnRn (NewCon new_ty)
-
-rnConDetails con locn (RecCon fields)
- = checkDupOrQualNames fld_doc field_names `thenRn_`
- mapRn rnField fields `thenRn` \ new_fields ->
- returnRn (RecCon new_fields)
+ bindTyVarsFVRn doc tvs $ \ new_tyvars ->
+ rnContext doc cxt `thenRn` \ (new_context, cxt_fvs) ->
+ rnConDetails doc locn details `thenRn` \ (new_details, det_fvs) ->
+ returnRn (ConDecl new_name new_tyvars new_context new_details locn,
+ cxt_fvs `plusFV` det_fvs)
+ where
+ doc = text "the definition of data constructor" <+> quotes (ppr name)
+
+rnConDetails doc locn (VanillaCon tys)
+ = mapAndUnzipRn (rnBangTy doc) tys `thenRn` \ (new_tys, fvs_s) ->
+ returnRn (VanillaCon new_tys, plusFVs fvs_s)
+
+rnConDetails doc locn (InfixCon ty1 ty2)
+ = rnBangTy doc ty1 `thenRn` \ (new_ty1, fvs1) ->
+ rnBangTy doc ty2 `thenRn` \ (new_ty2, fvs2) ->
+ returnRn (InfixCon new_ty1 new_ty2, fvs1 `plusFV` fvs2)
+
+rnConDetails doc locn (NewCon ty mb_field)
+ = rnHsType doc ty `thenRn` \ (new_ty, fvs) ->
+ rn_field mb_field `thenRn` \ new_mb_field ->
+ returnRn (NewCon new_ty new_mb_field, fvs)
+ where
+ rn_field Nothing = returnRn Nothing
+ rn_field (Just f) =
+ lookupBndrRn f `thenRn` \ new_f ->
+ returnRn (Just new_f)
+
+rnConDetails doc locn (RecCon fields)
+ = checkDupOrQualNames doc field_names `thenRn_`
+ mapAndUnzipRn (rnField doc) fields `thenRn` \ (new_fields, fvs_s) ->
+ returnRn (RecCon new_fields, plusFVs fvs_s)