diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-11-29 16:15:23 +0100 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-11-29 16:15:23 +0100 |
commit | 46e48ad854f4c5f47b1a4dbf4059bf59e0bea7df (patch) | |
tree | 7d3273e61e70f70e7102f00bcaf8e4cda15576f6 /src/Data/Array | |
parent | 0d06aadc72635011ef4c2ac4d7f45ece42817470 (diff) |
Improve scastToMixed's implementation
Diffstat (limited to 'src/Data/Array')
-rw-r--r-- | src/Data/Array/Nested/Internal/Shaped.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Data/Array/Nested/Internal/Shaped.hs b/src/Data/Array/Nested/Internal/Shaped.hs index 76e0e6d..2a8c206 100644 --- a/src/Data/Array/Nested/Internal/Shaped.hs +++ b/src/Data/Array/Nested/Internal/Shaped.hs @@ -488,8 +488,8 @@ stoMixed (Shaped arr) = arr -- compatibility check. scastToMixed :: forall sh sh' a. (Elt a, Rank sh ~ Rank sh') => IShX sh' -> Shaped sh a -> Mixed sh' a -scastToMixed shx (Shaped arr) - | Refl <- lemAppNil @sh' - , Refl <- lemAppNil @(MapJust sh) - , Refl <- lemRankMapJust (shCvtXS' @sh (mshape arr)) - = mcast (ssxFromShape (mshape arr)) shx (Proxy @'[]) arr +scastToMixed shx (Shaped arr) = + case shxEqual shx (mshape arr) of + Just Refl -> arr + Nothing -> error $ "scastToMixed: Given shape (" ++ show shx ++ ") is not equal to " ++ + "the shape of the array (" ++ show (mshape arr) ++ ")" |