aboutsummaryrefslogtreecommitdiff
path: root/src/Data/Array/Nested/Ranked/Shape.hs
diff options
context:
space:
mode:
authorMikolaj Konarski <mikolaj.konarski@funktory.com>2026-04-04 12:09:08 +0200
committerMikolaj Konarski <mikolaj.konarski@funktory.com>2026-04-04 12:09:08 +0200
commit53bc096c807fc63cfe5f1102131b475deb5e21ca (patch)
tree63115ff12a4bb5cb656164718163b885f7b91d27 /src/Data/Array/Nested/Ranked/Shape.hs
parenta9ac62f66e45e64f83043e0ebda04f0b4b80b913 (diff)
Remove almost all unsafeCoerce
Diffstat (limited to 'src/Data/Array/Nested/Ranked/Shape.hs')
-rw-r--r--src/Data/Array/Nested/Ranked/Shape.hs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/Data/Array/Nested/Ranked/Shape.hs b/src/Data/Array/Nested/Ranked/Shape.hs
index b0fb30d..6d94c8d 100644
--- a/src/Data/Array/Nested/Ranked/Shape.hs
+++ b/src/Data/Array/Nested/Ranked/Shape.hs
@@ -38,7 +38,6 @@ import GHC.IsList (IsList)
import GHC.IsList qualified as IsList
import GHC.TypeLits
import GHC.TypeNats qualified as TN
-import Unsafe.Coerce (unsafeCoerce)
import Data.Array.Nested.Lemmas
import Data.Array.Nested.Mixed.Shape
@@ -291,7 +290,7 @@ ixrToLinear :: Num i => IShR m -> IxR m i -> i
ixrToLinear (ShR sh) ix = ixxToLinear sh (ixxFromIxR ix)
ixxFromIxR :: IxR n i -> IxX (Replicate n Nothing) i
-ixxFromIxR = unsafeCoerce -- TODO: switch to coerce once newtypes overhauled
+ixxFromIxR = coerce
{-# INLINEABLE ixrFromLinear #-}
ixrFromLinear :: forall i m. Num i => IShR m -> Int -> IxR m i
@@ -299,8 +298,8 @@ ixrFromLinear (ShR sh) i
| Refl <- lemRankReplicate (Proxy @m)
= ixrFromIxX $ ixxFromLinear sh i
-ixrFromIxX :: IxX sh i -> IxR (Rank sh) i
-ixrFromIxX = unsafeCoerce -- TODO: switch to coerce once newtypes overhauled
+ixrFromIxX :: IxX (Replicate n Nothing) i -> IxR n i
+ixrFromIxX = coerce
shrEnum :: IShR n -> [IIxR n]
shrEnum = shrEnum'
@@ -309,8 +308,7 @@ shrEnum = shrEnum'
shrEnum' :: forall i n. Num i => IShR n -> [IxR n i]
shrEnum' (ShR sh)
| Refl <- lemRankReplicate (Proxy @n)
- = (unsafeCoerce :: [IxX (Replicate n Nothing) i] -> [IxR n i]) $ shxEnum' sh
- -- TODO: switch to coerce once newtypes overhauled
+ = (coerce :: [IxX (Replicate n Nothing) i] -> [IxR n i]) $ shxEnum' sh
-- * Ranked shapes