aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested/Convert.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/Array/Nested/Convert.hs')
-rw-r--r--src/Data/Array/Nested/Convert.hs19
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