diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-04-14 12:28:05 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-04-14 12:28:05 +0200 |
commit | 3defbdadab5080fc1f44895c06297d58ff3f5a43 (patch) | |
tree | 2717243947e3f4ae01e0a76ce71d367f61812ee6 /src/Data/Array/Nested/Internal.hs | |
parent | cde40eeb9560919fa464f14c76edc1aae1dac43b (diff) |
Make XArray a newtype
Diffstat (limited to 'src/Data/Array/Nested/Internal.hs')
-rw-r--r-- | src/Data/Array/Nested/Internal.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs index 15d72f0..eb4ef22 100644 --- a/src/Data/Array/Nested/Internal.hs +++ b/src/Data/Array/Nested/Internal.hs @@ -525,10 +525,14 @@ instance (KnownShape sh, Elt a) => Elt (Shaped sh a) where vecs) --- Utility function to satisfy the type checker sometimes +-- Utility functions to satisfy the type checker sometimes + rewriteMixed :: sh1 :~: sh2 -> Mixed sh1 a -> Mixed sh2 a rewriteMixed Refl x = x +coerceMixedXArray :: Coercible (Mixed sh a) (XArray sh a) => XArray sh a -> Mixed sh a +coerceMixedXArray = coerce + -- ====== API OF RANKED ARRAYS ====== -- @@ -583,7 +587,7 @@ rsumOuter1 :: forall n a. rsumOuter1 (Ranked arr) | Dict <- lemKnownReplicate (Proxy @n) = Ranked - . coerce @(XArray (Replicate n Nothing) a) @(Mixed (Replicate n Nothing) a) + . coerceMixedXArray . X.sumOuter (() :$? SZX) (knownShapeX @(Replicate n Nothing)) . coerce @(Mixed (Replicate (S n) Nothing) a) @(XArray (Replicate (S n) Nothing) a) $ arr @@ -651,7 +655,7 @@ ssumOuter1 :: forall sh n a. ssumOuter1 (Shaped arr) | Dict <- lemKnownMapJust (Proxy @sh) = Shaped - . coerce @(XArray (MapJust sh) a) @(Mixed (MapJust sh) a) + . coerceMixedXArray . X.sumOuter (natSing @n :$@ SZX) (knownShapeX @(MapJust sh)) . coerce @(Mixed (Just n : MapJust sh) a) @(XArray (Just n : MapJust sh) a) $ arr |