+-- If a family tycon with instance types is given, the current tycon is an
+-- instance of that family and we need to
+--
+-- (1) create a coercion that identifies the family instance type and the
+-- representation type from Step (1); ie, it is of the form
+-- `Co tvs :: F ts :=: R tvs', where `Co' is the name of the coercion,
+-- `F' the family tycon and `R' the (derived) representation tycon,
+-- and
+-- (2) produce a `TyConParent' value containing the parent and coercion
+-- information.
+--
+mkParentInfo :: Maybe (TyCon, [Type])
+ -> Name -> [TyVar]
+ -> TyCon
+ -> TcRnIf m n TyConParent
+mkParentInfo Nothing _ _ _ =
+ return NoParentTyCon
+mkParentInfo (Just (family, instTys)) tc_name tvs rep_tycon =
+ do { -- Create the coercion
+ ; co_tycon_name <- newImplicitBinder tc_name mkInstTyCoOcc
+ ; let co_tycon = mkFamInstCoercion co_tycon_name tvs
+ family instTys rep_tycon
+ ; return $ FamilyTyCon family instTys co_tycon
+ }
+