aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested/Ranked/Shape.hs
diff options
context:
space:
mode:
authorMikolaj Konarski <mikolaj.konarski@funktory.com>2026-03-16 14:36:36 +0100
committerMikolaj Konarski <mikolaj.konarski@funktory.com>2026-03-16 14:36:36 +0100
commitfc2a1370d67f12b50e3e5750d17aefd33bc3d8a3 (patch)
tree5a3bb2d84adcd6e9bca74034d884837996467ea1 /src/Data/Array/Nested/Ranked/Shape.hs
parent8409fa81c7b31bf8ace0b1f219ba6a1a7cbdf2de (diff)
Fill and clean up *TakeIx and *DropIx functionsmvecsReplicate
Diffstat (limited to 'src/Data/Array/Nested/Ranked/Shape.hs')
-rw-r--r--src/Data/Array/Nested/Ranked/Shape.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Data/Array/Nested/Ranked/Shape.hs b/src/Data/Array/Nested/Ranked/Shape.hs
index e44ab64..c5cdf6b 100644
--- a/src/Data/Array/Nested/Ranked/Shape.hs
+++ b/src/Data/Array/Nested/Ranked/Shape.hs
@@ -422,6 +422,16 @@ shrTail
| Refl <- lemReplicateSucc @(Nothing @Nat) (Proxy @n)
= coerce (shxTail @_ @_ @i)
+{-# INLINEABLE shrTakeIx #-}
+shrTakeIx :: forall n n' i j. Proxy n' -> IxR n j -> ShR (n + n') i -> ShR n i
+shrTakeIx _ ZIR _ = ZSR
+shrTakeIx p (_ :.: idx) sh = case sh of n :$: sh' -> n :$: shrTakeIx p idx sh'
+
+{-# INLINEABLE shrDropIx #-}
+shrDropIx :: forall n n' i j. IxR n j -> ShR (n + n') i -> ShR n' i
+shrDropIx ZIR long = long
+shrDropIx (_ :.: short) long = case long of _ :$: long' -> shrDropIx short long'
+
shrInit :: forall n i. ShR (n + 1) i -> ShR n i
shrInit
| Refl <- lemReplicateSucc @(Nothing @Nat) (Proxy @n)