aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested/Internal/Ranked.hs
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-06-09 20:47:09 +0200
committerTom Smeding <tom@tomsmeding.com>2024-06-09 20:47:30 +0200
commit5763bf70dc67c5437207ff8e9dd08585d2ea5384 (patch)
tree8b68dae165940368925a3cbe816a61a65eb23b68 /src/Data/Array/Nested/Internal/Ranked.hs
parentcb98a56767d50fe92790ae4f48a3efbb28aab90a (diff)
Concatenation of arrays for M and R
What should the type of sconcat be?
Diffstat (limited to 'src/Data/Array/Nested/Internal/Ranked.hs')
-rw-r--r--src/Data/Array/Nested/Internal/Ranked.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Data/Array/Nested/Internal/Ranked.hs b/src/Data/Array/Nested/Internal/Ranked.hs
index 9383b08..3e911ac 100644
--- a/src/Data/Array/Nested/Internal/Ranked.hs
+++ b/src/Data/Array/Nested/Internal/Ranked.hs
@@ -18,7 +18,7 @@
{-# OPTIONS_GHC -fplugin GHC.TypeLits.KnownNat.Solver #-}
module Data.Array.Nested.Internal.Ranked where
-import Prelude hiding (mappend)
+import Prelude hiding (mappend, mconcat)
import Control.DeepSeq (NFData)
import Control.Monad.ST
@@ -109,6 +109,8 @@ instance Elt a => Elt (Ranked n a) where
mtranspose perm (M_Ranked arr) = M_Ranked (mtranspose perm arr)
+ mconcat l = M_Ranked (mconcat (coerce l))
+
type ShapeTree (Ranked n a) = (IShR n, ShapeTree a)
mshapeTree (Ranked arr) = first shCvtXR' (mshapeTree arr)
@@ -272,6 +274,11 @@ rtranspose perm arr
| otherwise
= error "Data.Array.Nested.rtranspose: Permutation longer than rank of array"
+rconcat :: forall n a. Elt a => NonEmpty (Ranked (n + 1) a) -> Ranked (n + 1) a
+rconcat
+ | Refl <- lemReplicateSucc @(Nothing @Nat) @n
+ = coerce mconcat
+
rappend :: forall n a. Elt a
=> Ranked (n + 1) a -> Ranked (n + 1) a -> Ranked (n + 1) a
rappend arr1 arr2