aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-04-14 13:14:28 +0200
committerTom Smeding <tom@tomsmeding.com>2024-04-14 13:14:28 +0200
commitcb76efab519341e73a282dd431f87358c508c6b6 (patch)
tree1d732a27b1fcee9dfd1d89f7cd1c741a21f6f356 /src
parent70d2edeb338c6acbe9943c4f8b24225bcb912211 (diff)
Fix type signature of 'append'
Diffstat (limited to 'src')
-rw-r--r--src/Data/Array/Mixed.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Data/Array/Mixed.hs b/src/Data/Array/Mixed.hs
index d9eb5f0..9a8ccfd 100644
--- a/src/Data/Array/Mixed.hs
+++ b/src/Data/Array/Mixed.hs
@@ -252,7 +252,13 @@ index xarr i
= let XArray arr' = indexPartial xarr i :: XArray '[] a
in S.unScalar arr'
-append :: forall sh a. (KnownShapeX sh, Storable a) => XArray sh a -> XArray sh a -> XArray sh a
+type family AddMaybe n m where
+ AddMaybe Nothing _ = Nothing
+ AddMaybe (Just _) Nothing = Nothing
+ AddMaybe (Just n) (Just m) = Just (n + m)
+
+append :: forall n m sh a. (KnownShapeX sh, Storable a)
+ => XArray (n : sh) a -> XArray (m : sh) a -> XArray (AddMaybe n m : sh) a
append (XArray a) (XArray b)
| Dict <- lemKnownINatRankSSX (knownShapeX @sh)
, Dict <- knownNatFromINat (Proxy @(Rank sh))