aboutsummaryrefslogtreecommitdiff
path: root/src/Data
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-11-22 11:58:44 +0100
committerTom Smeding <tom@tomsmeding.com>2024-11-22 11:58:44 +0100
commit03b7cea970d0840a913b6e64a9439fb115dea8d0 (patch)
tree57b0fa5393a8d76188b423cece5610aec4e94b4a /src/Data
parent5f8b9ea3a9bacfec0fb1558a0199ea7952b2641e (diff)
Fix X.empty
S.constant always evaluates its argument.
Diffstat (limited to 'src/Data')
-rw-r--r--src/Data/Array/Mixed/XArray.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/Data/Array/Mixed/XArray.hs b/src/Data/Array/Mixed/XArray.hs
index 999ccc3..81b92c5 100644
--- a/src/Data/Array/Mixed/XArray.hs
+++ b/src/Data/Array/Mixed/XArray.hs
@@ -310,8 +310,10 @@ toList1 (XArray arr) = S.toList arr
empty :: forall sh a. Storable a => IShX sh -> XArray sh a
empty sh
| Dict <- lemKnownNatRank sh
- = XArray (S.constant (shxToList sh)
- (error $ "Data.Array.Mixed.empty: shape was not empty: " ++ show sh))
+ , shxSize sh == 0
+ = XArray (S.fromVector (shxToList sh) VS.empty)
+ | otherwise
+ = error $ "Data.Array.Mixed.empty: shape was not empty: " ++ show sh
slice :: SNat i -> SNat n -> XArray (Just (i + n + k) : sh) a -> XArray (Just n : sh) a
slice i n (XArray arr) = XArray (S.slice [(fromSNat' i, fromSNat' n)] arr)