aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Mixed/XArray.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/Mixed/XArray.hs
parentcb98a56767d50fe92790ae4f48a3efbb28aab90a (diff)
Concatenation of arrays for M and R
What should the type of sconcat be?
Diffstat (limited to 'src/Data/Array/Mixed/XArray.hs')
-rw-r--r--src/Data/Array/Mixed/XArray.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/Data/Array/Mixed/XArray.hs b/src/Data/Array/Mixed/XArray.hs
index e93ffca..20f5c7a 100644
--- a/src/Data/Array/Mixed/XArray.hs
+++ b/src/Data/Array/Mixed/XArray.hs
@@ -18,7 +18,9 @@ import Control.DeepSeq (NFData(..))
import Data.Array.Ranked qualified as ORB
import Data.Array.RankedS qualified as S
import Data.Coerce
+import Data.Foldable (toList)
import Data.Kind
+import Data.List.NonEmpty (NonEmpty)
import Data.Proxy
import Data.Type.Equality
import Data.Type.Ord
@@ -117,6 +119,14 @@ append ssh (XArray a) (XArray b)
| Dict <- lemKnownNatRankSSX ssh
= XArray (S.append a b)
+-- | All arrays must have the same shape, except possibly for the outermost
+-- dimension.
+concat :: Storable a
+ => StaticShX sh -> NonEmpty (XArray (Nothing : sh) a) -> XArray (Nothing : sh) a
+concat ssh l
+ | Dict <- lemKnownNatRankSSX ssh
+ = XArray (S.concatOuter (coerce (toList l)))
+
-- | If the prefix of the shape of the input array (@sh@) is empty (i.e.
-- contains a zero), then there is no way to deduce the full shape of the output
-- array (more precisely, the @sh2@ part): that could only come from calling