@@ -366,16 +366,16 @@ toImpRefOp refDest' m = do
366366 ans <- liftBuilderImp $ emitBlock (sink body')
367367 storeAtom accDest ans
368368 False -> case accTy of
369- TabTy d (b :> t) eltTy -> do
370- let ixTy = IxType t d
369+ TabPi t -> do
370+ let ixTy = tabIxType t
371371 n <- indexSetSizeImp ixTy
372372 emitLoop noHint Fwd n \ i -> do
373373 idx <- unsafeFromOrdinalImp (sink ixTy) i
374374 xElt <- liftBuilderImp $ tabApp (sink x) (sink idx)
375375 yElt <- liftBuilderImp $ tabApp (sink y) (sink idx)
376- eltTy' <- applySubst (b @> SubstVal idx) eltTy
376+ eltTy <- instantiateTabPiTy (sink t) idx
377377 ithDest <- indexDest (sink accDest) idx
378- liftMonoidCombine ithDest eltTy' (sink bc) xElt yElt
378+ liftMonoidCombine ithDest eltTy (sink bc) xElt yElt
379379 _ -> error $ " Base monoid type mismatch: can't lift " ++
380380 pprint baseTy ++ " to " ++ pprint accTy
381381
@@ -578,15 +578,15 @@ toImpTypedHof (TypedHof (EffTy _ resultTy') hof) = do
578578 alphaEq xTy accTy >>= \ case
579579 True -> storeAtom accDest x
580580 False -> case accTy of
581- TabTy d (b :> t) eltTy -> do
582- let ixTy = IxType t d
581+ TabPi t -> do
582+ let ixTy = tabIxType t
583583 n <- indexSetSizeImp ixTy
584584 emitLoop noHint Fwd n \ i -> do
585585 idx <- unsafeFromOrdinalImp (sink ixTy) i
586586 x' <- sinkM x
587- eltTy' <- applySubst (b @> SubstVal idx) eltTy
587+ eltTy <- instantiateTabPiTy (sink t) idx
588588 ithDest <- indexDest (sink accDest) idx
589- liftMonoidEmpty ithDest eltTy' x'
589+ liftMonoidEmpty ithDest eltTy x'
590590 _ -> error $ " Base monoid type mismatch: can't lift " ++
591591 pprint xTy ++ " to " ++ pprint accTy
592592
@@ -1002,11 +1002,11 @@ buildGarbageVal ty =
10021002-- === Operations on dests ===
10031003
10041004indexDest :: Emits n => Dest n -> SAtom n -> SubstImpM i n (Dest n )
1005- indexDest (Dest destValTy @ ( TabTy d (b :> t) eltTy ) tree) i = do
1006- eltTy' <- applySubst (b @> SubstVal i) eltTy
1007- ord <- ordinalImp (IxType t d ) i
1008- leafTys <- typeToTree destValTy
1009- Dest eltTy' <$> forM (zipTrees leafTys tree) \ (leafTy, ptr) -> do
1005+ indexDest (Dest ( TabPi tabTy ) tree) i = do
1006+ eltTy <- instantiateTabPiTy tabTy i
1007+ ord <- ordinalImp (tabIxType tabTy ) i
1008+ leafTys <- typeToTree $ TabPi tabTy
1009+ Dest eltTy <$> forM (zipTrees leafTys tree) \ (leafTy, ptr) -> do
10101010 BufferType ixStruct _ <- return $ getRefBufferType leafTy
10111011 offset <- computeOffsetImp ixStruct ord
10121012 impOffset ptr offset
@@ -1026,10 +1026,10 @@ indexRepValParam :: Emits n
10261026 => SRepVal n -> SAtom n -> (SType n -> SType n )
10271027 -> (IExpr n -> SubstImpM i n (IExpr n ))
10281028 -> SubstImpM i n (SRepVal n )
1029- indexRepValParam (RepVal tabTy @ (TabPi ( TabPiType d (b :> t) eltTy) ) vals) i tyFunc func = do
1030- eltTy' <- applySubst (b @> SubstVal i) eltTy
1031- ord <- ordinalImp (IxType t d ) i
1032- leafTys <- typeToTree tabTy
1029+ indexRepValParam (RepVal (TabPi tabTy ) vals) i tyFunc func = do
1030+ eltTy <- instantiateTabPiTy tabTy i
1031+ ord <- ordinalImp (tabIxType tabTy ) i
1032+ leafTys <- typeToTree ( TabPi tabTy)
10331033 vals' <- forM (zipTrees leafTys vals) \ (leafTy, ptr) -> do
10341034 BufferPtr (BufferType ixStruct _) <- return $ getIExprInterpretation leafTy
10351035 offset <- computeOffsetImp ixStruct ord
@@ -1041,7 +1041,7 @@ indexRepValParam (RepVal tabTy@(TabPi (TabPiType d (b:>t) eltTy)) vals) i tyFunc
10411041 _ -> func ptr'
10421042 -- `func` may have changed the types of the `vals'`. The caller must also
10431043 -- supply `tyFunc` to reflect that change in the SType.
1044- return $ RepVal (tyFunc eltTy' ) vals'
1044+ return $ RepVal (tyFunc eltTy) vals'
10451045indexRepValParam _ _ _ _ = error " expected table type"
10461046{-# INLINE indexRepValParam #-}
10471047
0 commit comments