diff options
author | Tom Smeding <tom@tomsmeding.com> | 2025-06-04 14:59:40 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2025-06-04 14:59:40 +0200 |
commit | 5d769178ee804c3804c9d7bf155ac2e46407eb3a (patch) | |
tree | 0866687a78a5ecdc411a938f288e43eae774fe70 /src/Data/Array/Nested/Mixed.hs | |
parent | 4261cb045081188a48bc8306f173166a79fcb1df (diff) |
Add shape checking to [rms]zip
Diffstat (limited to 'src/Data/Array/Nested/Mixed.hs')
-rw-r--r-- | src/Data/Array/Nested/Mixed.hs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/Data/Array/Nested/Mixed.hs b/src/Data/Array/Nested/Mixed.hs index 9ec8d9d..54f8fe6 100644 --- a/src/Data/Array/Nested/Mixed.hs +++ b/src/Data/Array/Nested/Mixed.hs @@ -815,8 +815,11 @@ mnest ssh arr = M_Nest (fst (shxSplitApp (Proxy @sh') ssh (mshape arr))) arr munNest :: Mixed sh (Mixed sh' a) -> Mixed (sh ++ sh') a munNest (M_Nest _ arr) = arr -mzip :: Mixed sh a -> Mixed sh b -> Mixed sh (a, b) -mzip = M_Tup2 +-- | The arguments must have equal shapes. If they do not, an error is raised. +mzip :: (Elt a, Elt b) => Mixed sh a -> Mixed sh b -> Mixed sh (a, b) +mzip a b + | Just Refl <- shxEqual (mshape a) (mshape b) = M_Tup2 a b + | otherwise = error "mzip: unequal shapes" munzip :: Mixed sh (a, b) -> (Mixed sh a, Mixed sh b) munzip (M_Tup2 a b) = (a, b) |