+ mk_alt dc = do
+ bndrs <- mapM (newLocalVar FSLIT("x")) $ dataConRepArgTys dc
+ return (bndrs, mkConApp dc (map Type var_tys ++ map Var bndrs))
+
+buildPArrayTyCon :: TyCon -> TyCon -> VM TyCon
+buildPArrayTyCon orig_tc vect_tc = fixV $ \repr_tc ->
+ do
+ name' <- cloneName mkPArrayTyConOcc orig_name
+ rhs <- buildPArrayTyConRhs orig_name vect_tc repr_tc
+ parray <- builtin parrayTyCon
+
+ liftDs $ buildAlgTyCon name'
+ tyvars
+ [] -- no stupid theta
+ rhs
+ rec_flag -- FIXME: is this ok?
+ False -- FIXME: no generics
+ False -- not GADT syntax
+ (Just $ mk_fam_inst parray vect_tc)
+ where
+ orig_name = tyConName orig_tc
+ tyvars = tyConTyVars vect_tc
+ rec_flag = boolToRecFlag (isRecursiveTyCon vect_tc)
+
+
+buildPArrayTyConRhs :: Name -> TyCon -> TyCon -> VM AlgTyConRhs
+buildPArrayTyConRhs orig_name vect_tc repr_tc
+ = do
+ data_con <- buildPArrayDataCon orig_name vect_tc repr_tc
+ return $ DataTyCon { data_cons = [data_con], is_enum = False }
+
+buildPArrayDataCon :: Name -> TyCon -> TyCon -> VM DataCon
+buildPArrayDataCon orig_name vect_tc repr_tc
+ = do
+ dc_name <- cloneName mkPArrayDataConOcc orig_name
+ shape <- tyConShape vect_tc
+ repr_tys <- mapM mkPArrayType types
+
+ liftDs $ buildDataCon dc_name
+ False -- not infix
+ (shapeStrictness shape ++ map (const NotMarkedStrict) repr_tys)
+ [] -- no field labels
+ (tyConTyVars vect_tc)
+ [] -- no existentials
+ [] -- no eq spec
+ [] -- no context
+ (shapeReprTys shape ++ repr_tys)
+ repr_tc
+ where
+ types = [ty | dc <- tyConDataCons vect_tc
+ , ty <- dataConRepArgTys dc]
+
+mkPADFun :: TyCon -> VM Var
+mkPADFun vect_tc
+ = newExportedVar (mkPADFunOcc $ getOccName vect_tc) =<< paDFunType vect_tc