diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2026-04-09 00:59:15 +0200 |
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2026-04-09 01:01:01 +0200 |
| commit | fe25edfd8e633a834a23d272bae8ccf456b63c26 (patch) | |
| tree | 85c94289bce1d4022786366304a3f189d56ba248 /src/Data/Array/Nested/Convert.hs | |
| parent | abfa3b9646c49fbac7bade84dd1a2973ccb5accb (diff) | |
Make equal-rank-coercibility part of the interface of ListXmove-Rank
Diffstat (limited to 'src/Data/Array/Nested/Convert.hs')
| -rw-r--r-- | src/Data/Array/Nested/Convert.hs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/Data/Array/Nested/Convert.hs b/src/Data/Array/Nested/Convert.hs index 671f40f..4ee2a71 100644 --- a/src/Data/Array/Nested/Convert.hs +++ b/src/Data/Array/Nested/Convert.hs @@ -46,6 +46,7 @@ import Unsafe.Coerce (unsafeCoerce) import Data.Array.Nested.Lemmas import Data.Array.Nested.Mixed +import Data.Array.Nested.Mixed.ListX import Data.Array.Nested.Mixed.Shape import Data.Array.Nested.Ranked.Base import Data.Array.Nested.Ranked.Shape @@ -58,9 +59,12 @@ import Data.Array.Nested.Types -- * To ranked ixrFromIxS :: forall sh i. IxS sh i -> IxR (Rank sh) i -ixrFromIxS = coerce - Prelude.. (unsafeCoerce :: IxX (MapJust sh) i -> IxX (Replicate (Rank sh) Nothing) i) - Prelude.. coerce +ixrFromIxS + | Refl <- lemRankReplicate (Proxy @(Rank sh)) + , Refl <- lemRankMapJust (Proxy @sh) + = coerce + Prelude.. (coerceEqualRankListX :: ListX (MapJust sh) i -> ListX (Replicate (Rank sh) Nothing) i) + Prelude.. coerce -- ixrFromIxX re-exported @@ -82,9 +86,12 @@ shrFromShX = coerce -- * To shaped ixsFromIxR :: forall sh i. IxR (Rank sh) i -> IxS sh i -ixsFromIxR = coerce - Prelude.. (unsafeCoerce :: IxX (Replicate (Rank sh) Nothing) i -> IxX (MapJust sh) i) - Prelude.. coerce +ixsFromIxR + | Refl <- lemRankReplicate (Proxy @(Rank sh)) + , Refl <- lemRankMapJust (Proxy @sh) + = coerce + Prelude.. (coerceEqualRankListX :: ListX (Replicate (Rank sh) Nothing) i -> ListX (MapJust sh) i) + Prelude.. coerce -- ixsFromIxX re-exported |
