More refactoring
[ghc-hetmet.git] / compiler / vectorise / VectUtils.hs
index 4982fcc..24a12ea 100644 (file)
@@ -2,7 +2,8 @@ module VectUtils (
   collectAnnTypeBinders, collectAnnTypeArgs, isAnnTypeArg,
   splitClosureTy,
   mkPADictType, mkPArrayType,
-  paDictArgType, paDictOfType, paMethod,
+  paDictArgType, paDictOfType,
+  paMethod, lengthPA, replicatePA,
   lookupPArrayFamInst,
   hoistExpr, takeHoisted
 ) where
@@ -115,6 +116,13 @@ paMethod method ty
       dict <- paDictOfType ty
       return $ mkApps (Var fn) [Type ty, dict]
 
+lengthPA :: CoreExpr -> VM CoreExpr
+lengthPA x = liftM (`App` x) (paMethod lengthPAVar (exprType x))
+
+replicatePA :: CoreExpr -> CoreExpr -> VM CoreExpr
+replicatePA len x = liftM (`mkApps` [len,x])
+                          (paMethod replicatePAVar (exprType x))
+
 lookupPArrayFamInst :: Type -> VM (TyCon, [Type])
 lookupPArrayFamInst ty = builtin parrayTyCon >>= (`lookupFamInst` [ty])