Commit 8d5e92db authored by rl@cse.unsw.edu.au's avatar rl@cse.unsw.edu.au

Fix generation of lengthPA

parent ddcf1140
......@@ -3,7 +3,7 @@ module VectMonad (
VM,
noV, tryV, maybeV, orElseV, fixV, localV, closedV, initV,
cloneName, newExportedVar, newLocalVar, newTyVar,
cloneName, newExportedVar, newLocalVar, newDummyVar, newTyVar,
Builtins(..), paDictTyCon, paDictDataCon,
builtin,
......@@ -297,6 +297,9 @@ newLocalVar fs ty
u <- liftDs newUnique
return $ mkSysLocal fs u ty
newDummyVar :: Type -> VM Var
newDummyVar = newLocalVar FSLIT("ds")
newTyVar :: FastString -> Kind -> VM Var
newTyVar fs k
= do
......
......@@ -315,20 +315,23 @@ paMethods = [(FSLIT("lengthPA"), buildLengthPA),
(FSLIT("replicatePA"), buildReplicatePA)]
buildLengthPA :: TyCon -> TyCon -> VM CoreExpr
buildLengthPA _ arr_tc
buildLengthPA vect_tc arr_tc
= do
arg <- newLocalVar FSLIT("xs") arg_ty
parr_ty <- mkPArrayType (mkTyConApp vect_tc arg_tys)
arg <- newLocalVar FSLIT("xs") parr_ty
let scrut = unwrapFamInstScrut arr_tc arg_tys (Var arg)
scrut_ty = exprType scrut
shape <- newLocalVar FSLIT("sel") shape_ty
body <- lengthPA (Var shape)
wilds <- mapM newDummyVar repr_tys
return . Lam arg
$ Case (Var arg) (mkWildId arg_ty) intPrimTy
[(DataAlt repr_dc, shape : map mkWildId repr_tys, body)]
$ Case scrut (mkWildId scrut_ty) intPrimTy
[(DataAlt repr_dc, shape : wilds, body)]
where
arg_ty = mkTyConApp arr_tc . mkTyVarTys $ tyConTyVars arr_tc
arg_tys = mkTyVarTys $ tyConTyVars arr_tc
[repr_dc] = tyConDataCons arr_tc
shape_ty : repr_tys = dataConRepArgTys repr_dc
-- data T = C0 t1 ... tm
-- ...
-- Ck u1 ... un
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment