where
arity = length reprs
-reprProducts :: Repr -> [Repr]
-reprProducts (SumRepr { sum_components = rs }) = rs
-reprProducts repr = [repr]
-
reprType :: Repr -> Type
reprType (ProdRepr { prod_tycon = tycon, prod_components = tys })
= mkTyConApp tycon tys
arrReprType :: Repr -> VM Type
arrReprType = mkPArrayType . reprType
-reprTys :: Repr -> [[Type]]
-reprTys (SumRepr { sum_components = prods }) = map prodTys prods
-reprTys prod = [prodTys prod]
-
-prodTys (ProdRepr { prod_components = tys }) = tys
-
-reprVars :: Repr -> VM [[Var]]
-reprVars = mapM (mapM (newLocalVar FSLIT("r"))) . reprTys
-
arrShapeTys :: Repr -> VM [Type]
arrShapeTys (SumRepr {})
= do
replicateShape :: Repr -> CoreExpr -> CoreExpr -> VM [CoreExpr]
replicateShape (ProdRepr {}) len _ = return [len]
+replicateShape (SumRepr {}) len tag
+ = do
+ rep <- builtin replicatePAIntPrimVar
+ up <- builtin upToPAIntPrimVar
+ return [len, Var rep `mkApps` [len, tag], Var up `App` len]
arrReprElemTys :: Repr -> [[Type]]
arrReprElemTys (SumRepr { sum_components = prods })