summaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-04-20 22:52:23 +0200
committerTom Smeding <tom@tomsmeding.com>2024-04-20 22:52:23 +0200
commita3149a6e039516e984f745cd6260ce95bf80dee4 (patch)
tree2ff5f955aaf5d229433bc80ee5114f1409ac95e9 /src/Data/Array/Nested
parentde1250a6837cc3b8cf168905e360845e9082c7d2 (diff)
slice
Diffstat (limited to 'src/Data/Array/Nested')
-rw-r--r--src/Data/Array/Nested/Internal.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs
index c8a0670..4e78647 100644
--- a/src/Data/Array/Nested/Internal.hs
+++ b/src/Data/Array/Nested/Internal.hs
@@ -517,6 +517,9 @@ mconstant :: forall sh a. (KnownShapeX sh, Storable a, Coercible (Mixed sh (Prim
=> IxX sh -> a -> Mixed sh a
mconstant sh x = coerce (mconstantP sh x)
+mslice :: (KnownShapeX sh, Elt a) => [(Int, Int)] -> Mixed sh a -> Mixed sh a
+mslice ivs = mlift $ \_ -> X.slice ivs
+
mliftPrim :: (KnownShapeX sh, Storable a)
=> (a -> a)
-> Mixed sh (Primitive a) -> Mixed sh (Primitive a)
@@ -959,6 +962,9 @@ rconstant :: forall n a. (KnownINat n, Storable a, Coercible (Mixed (Replicate n
=> IxR n -> a -> Ranked n a
rconstant sh x = coerce (rconstantP sh x)
+rslice :: (KnownINat n, Elt a) => [(Int, Int)] -> Ranked n a -> Ranked n a
+rslice ivs = rlift $ \_ -> X.slice ivs
+
rfromList :: forall n a. (KnownINat n, Elt a) => NonEmpty (Ranked n a) -> Ranked (S n) a
rfromList l
| Dict <- lemKnownReplicate (Proxy @n)
@@ -1101,6 +1107,9 @@ sconstant :: forall sh a. (KnownShape sh, Storable a, Coercible (Mixed (MapJust
=> a -> Shaped sh a
sconstant x = coerce (sconstantP @sh x)
+sslice :: (KnownShape sh, Elt a) => [(Int, Int)] -> Shaped sh a -> Shaped sh a
+sslice ivs = slift $ \_ -> X.slice ivs
+
sfromList :: forall n sh a. (KnownNat n, KnownShape sh, Elt a)
=> NonEmpty (Shaped sh a) -> Shaped (n : sh) a
sfromList l