From abfa3b9646c49fbac7bade84dd1a2973ccb5accb Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Thu, 9 Apr 2026 00:45:04 +0200 Subject: Justify two unsafeCoerces using partial coerce --- src/Data/Array/Nested/Convert.hs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Data/Array/Nested/Convert.hs b/src/Data/Array/Nested/Convert.hs index 155a1a7..671f40f 100644 --- a/src/Data/Array/Nested/Convert.hs +++ b/src/Data/Array/Nested/Convert.hs @@ -57,9 +57,10 @@ import Data.Array.Nested.Types -- * To ranked --- This unsafeCoerce, exceptionally, can't be eliminated using newtype coercions. -ixrFromIxS :: IxS sh i -> IxR (Rank sh) i -ixrFromIxS = unsafeCoerce +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 -- ixrFromIxX re-exported @@ -80,9 +81,10 @@ shrFromShX = coerce -- * To shaped --- This unsafeCoerce, exceptionally, can't be eliminated using newtype coercions. -ixsFromIxR :: IxR (Rank sh) i -> IxS sh i -ixsFromIxR = unsafeCoerce +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 -- ixsFromIxX re-exported -- cgit v1.3