-arrReprElemTys :: Repr -> VM [[Type]]
-arrReprElemTys (SumRepr { sum_components = prods })
- = mapM arrProdElemTys prods
-arrReprElemTys prod@(ProdRepr {})
- = do
- tys <- arrProdElemTys prod
- return [tys]
-arrReprElemTys (IdRepr ty) = return [[ty]]
-arrReprElemTys (VoidRepr { void_tycon = tycon })
- = return [[mkTyConApp tycon []]]
-
-arrProdElemTys (ProdRepr { prod_components = [] })
- = do
- void <- builtin voidTyCon
- return [mkTyConApp void []]
-arrProdElemTys (ProdRepr { prod_components = tys })
- = return tys
-arrProdElemTys (IdRepr ty) = return [ty]
-arrProdElemTys (VoidRepr { void_tycon = tycon })
- = return [mkTyConApp tycon []]
-
-arrReprTys :: Repr -> VM [[Type]]
-arrReprTys repr = mapM (mapM mkPArrayType) =<< arrReprElemTys repr
+arrSelector :: Repr -> [CoreExpr] -> VM (CoreExpr, CoreExpr, CoreExpr)
+arrSelector (SumRepr {}) [len, sel, is] = return (len, sel, is)
+arrSelector (EnumRepr {}) [len, sel, is] = return (len, sel, is)
+
+emptyArrRepr :: Repr -> VM [CoreExpr]
+emptyArrRepr (SumRepr { sum_components = prods })
+ = liftM concat $ mapM emptyArrRepr prods
+emptyArrRepr (ProdRepr { prod_components = [] })
+ = return [Var unitDataConId]
+emptyArrRepr (ProdRepr { prod_components = tys })
+ = mapM emptyPA tys
+emptyArrRepr (IdRepr ty)
+ = liftM singleton $ emptyPA ty
+emptyArrRepr (VoidRepr { void_tycon = tycon })
+ = liftM singleton $ emptyPA (mkTyConApp tycon [])
+emptyArrRepr (EnumRepr { enum_tycon = tycon })
+ = return []
+
+arrReprTys :: Repr -> VM [Type]
+arrReprTys (SumRepr { sum_components = reprs })
+ = liftM concat $ mapM arrReprTys reprs
+arrReprTys (ProdRepr { prod_components = [] })
+ = return [unitTy]
+arrReprTys (ProdRepr { prod_components = tys })
+ = mapM mkPArrayType tys
+arrReprTys (IdRepr ty)
+ = liftM singleton $ mkPArrayType ty
+arrReprTys (VoidRepr { void_tycon = tycon })
+ = liftM singleton $ mkPArrayType (mkTyConApp tycon [])
+arrReprTys (EnumRepr {})
+ = return []
+
+arrReprTys' :: Repr -> VM [[Type]]
+arrReprTys' (SumRepr { sum_components = reprs })
+ = mapM arrReprTys reprs
+arrReprTys' repr = liftM singleton $ arrReprTys repr