From 62c4d56bfb75e933b5307930859f6c9366217ab1 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Wed, 9 Oct 2024 09:25:07 +0200 Subject: Add rToMixed and stoMixed These are somewhat redundant because one can just open up the Ranked and Shaped newtype constructors, but let's complete the triangle of conversion functions. --- src/Data/Array/Nested/Internal/Ranked.hs | 3 +++ src/Data/Array/Nested/Internal/Shaped.hs | 3 +++ 2 files changed, 6 insertions(+) (limited to 'src/Data/Array/Nested') diff --git a/src/Data/Array/Nested/Internal/Ranked.hs b/src/Data/Array/Nested/Internal/Ranked.hs index 735d1a3..ffa1cea 100644 --- a/src/Data/Array/Nested/Internal/Ranked.hs +++ b/src/Data/Array/Nested/Internal/Ranked.hs @@ -524,3 +524,6 @@ mtoRanked arr convSh (smn :$% (sh :: IShX sh'T)) | Refl <- lemReplicateSucc @(Nothing @Nat) @(Rank sh'T) = SUnknown (fromSMayNat' smn) :$% convSh sh + +rtoMixed :: forall n a. Elt a => Ranked n a -> Mixed (Replicate n Nothing) a +rtoMixed (Ranked arr) = arr diff --git a/src/Data/Array/Nested/Internal/Shaped.hs b/src/Data/Array/Nested/Internal/Shaped.hs index 995507f..023f96c 100644 --- a/src/Data/Array/Nested/Internal/Shaped.hs +++ b/src/Data/Array/Nested/Internal/Shaped.hs @@ -459,3 +459,6 @@ mcastToShaped arr targetsh , Refl <- lemAppNil @(MapJust sh') , Refl <- lemRankMapJust targetsh = Shaped (mcast (ssxFromShape (mshape arr)) (shCvtSX targetsh) (Proxy @'[]) arr) + +stoMixed :: forall sh a. Shaped sh a -> Mixed (MapJust sh) a +stoMixed (Shaped arr) = arr -- cgit v1.2.3-70-g09d2