aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Mixed.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-05-20 17:21:21 +0200
committerTom Smeding <tom@tomsmeding.com>2024-05-20 17:21:35 +0200
commit52c0237fbdbc3c99ee6565ba18250360a330fb8b (patch)
treee3b7b11d81f557dfbff9df043198e9e7c50fb569 /src/Data/Array/Mixed.hs
parent16e52d87e9955628a016946c10515c39ce4ef1d0 (diff)
Rerank on primitive arrays
Diffstat (limited to 'src/Data/Array/Mixed.hs')
-rw-r--r--src/Data/Array/Mixed.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Data/Array/Mixed.hs b/src/Data/Array/Mixed.hs
index 33c0dd6..2f23903 100644
--- a/src/Data/Array/Mixed.hs
+++ b/src/Data/Array/Mixed.hs
@@ -320,12 +320,22 @@ listxDrop long (_ ::% short) = case long of _ ::% long' -> listxDrop long' short
ixDrop :: forall sh sh' i. IxX (sh ++ sh') i -> IxX sh i -> IxX sh' i
ixDrop = coerce (listxDrop @(Const i) @(Const i))
+shDropSSX :: forall sh sh' i. ShX (sh ++ sh') i -> StaticShX sh -> ShX sh' i
+shDropSSX = coerce (listxDrop @(SMayNat i SNat) @(SMayNat () SNat))
+
shDropIx :: forall sh sh' i j. ShX (sh ++ sh') i -> IxX sh j -> ShX sh' i
shDropIx = coerce (listxDrop @(SMayNat i SNat) @(Const j))
shDropSh :: forall sh sh' i. ShX (sh ++ sh') i -> ShX sh i -> ShX sh' i
shDropSh = coerce (listxDrop @(SMayNat i SNat) @(SMayNat i SNat))
+shTakeSSX :: forall sh sh' i. Proxy sh' -> ShX (sh ++ sh') i -> StaticShX sh -> ShX sh i
+shTakeSSX _ = flip go
+ where
+ go :: StaticShX sh1 -> ShX (sh1 ++ sh') i -> ShX sh1 i
+ go ZKX _ = ZSX
+ go (_ :!% ssh1) (n :$% sh) = n :$% go ssh1 sh
+
ssxDropIx :: forall sh sh' i. StaticShX (sh ++ sh') -> IxX sh i -> StaticShX sh'
ssxDropIx = coerce (listxDrop @(SMayNat () SNat) @(Const i))