-genForAllTy :: SrcSpan -> TyCon
- -> (LHsType RdrName -> LHsType RdrName)
- -> LHsType RdrName
--- Wrap a forall type for the variables of the TyCOn
-genForAllTy loc tc thing_inside
- = L loc $ mkExplicitHsForAllTy (userHsTyVarBndrs (map (L loc) tvs)) (L loc []) $
- thing_inside (nlHsTyConApp (getRdrName tc) (map nlHsTyVar tvs))
- where
- tvs = map (mkRdrUnqual . getOccName) (tyConTyVars tc)
- -- We can't use getRdrName because that makes an Exact RdrName
- -- and we can't put them in the LocalRdrEnv
+mkParentType :: TyCon -> Type
+-- Turn the representation tycon of a family into
+-- a use of its family constructor
+mkParentType tc
+ = case tyConFamInst_maybe tc of
+ Nothing -> mkTyConApp tc (mkTyVarTys (tyConTyVars tc))
+ Just (fam_tc,tys) -> mkTyConApp fam_tc tys