+data TyConRepr = TyConRepr {
+ repr_tyvars :: [TyVar]
+ , repr_tys :: [[Type]]
+
+ , repr_embed_tys :: [[Type]]
+ , repr_prod_tycons :: [Maybe TyCon]
+ , repr_prod_tys :: [Type]
+ , repr_sum_tycon :: Maybe TyCon
+ , repr_type :: Type
+ }
+
+mkTyConRepr :: TyCon -> VM TyConRepr
+mkTyConRepr vect_tc
+ = do
+ embed_tys <- mapM (mapM mkEmbedType) rep_tys
+ prod_tycons <- mapM (mk_tycon prodTyCon) rep_tys
+ sum_tycon <- mk_tycon sumTyCon rep_tys
+
+ let prod_tys = zipWith mk_tc_app_maybe prod_tycons embed_tys
+
+ return $ TyConRepr {
+ repr_tyvars = tyvars
+ , repr_tys = rep_tys
+
+ , repr_embed_tys = embed_tys
+ , repr_prod_tycons = prod_tycons
+ , repr_prod_tys = prod_tys
+ , repr_sum_tycon = sum_tycon
+ , repr_type = mk_tc_app_maybe sum_tycon prod_tys
+ }
+ where
+ tyvars = tyConTyVars vect_tc
+ data_cons = tyConDataCons vect_tc
+ rep_tys = map dataConRepArgTys data_cons
+
+ mk_tycon get_tc tys
+ | n > 1 = builtin (Just . get_tc n)
+ | otherwise = return Nothing
+ where n = length tys
+
+ mk_tc_app_maybe Nothing [] = unitTy
+ mk_tc_app_maybe Nothing [ty] = ty
+ mk_tc_app_maybe (Just tc) tys = mkTyConApp tc tys
+
+{-