diff options
| author | Mikolaj Konarski <mikolaj.konarski@funktory.com> | 2026-04-04 12:09:08 +0200 |
|---|---|---|
| committer | Mikolaj Konarski <mikolaj.konarski@funktory.com> | 2026-04-04 12:09:08 +0200 |
| commit | 53bc096c807fc63cfe5f1102131b475deb5e21ca (patch) | |
| tree | 63115ff12a4bb5cb656164718163b885f7b91d27 /src/Data/Array/Nested/Shaped | |
| parent | a9ac62f66e45e64f83043e0ebda04f0b4b80b913 (diff) | |
Remove almost all unsafeCoerce
Diffstat (limited to 'src/Data/Array/Nested/Shaped')
| -rw-r--r-- | src/Data/Array/Nested/Shaped/Shape.hs | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/Data/Array/Nested/Shaped/Shape.hs b/src/Data/Array/Nested/Shaped/Shape.hs index 97d1559..c39d482 100644 --- a/src/Data/Array/Nested/Shaped/Shape.hs +++ b/src/Data/Array/Nested/Shaped/Shape.hs @@ -36,7 +36,6 @@ import GHC.Exts (build, withDict) import GHC.IsList (IsList) import GHC.IsList qualified as IsList import GHC.TypeLits -import Unsafe.Coerce (unsafeCoerce) import Data.Array.Nested.Mixed.Shape import Data.Array.Nested.Permutation @@ -267,22 +266,21 @@ ixsToLinear :: Num i => ShS sh -> IxS sh i -> i ixsToLinear (ShS sh) ix = ixxToLinear sh (ixxFromIxS ix) ixxFromIxS :: IxS sh i -> IxX (MapJust sh) i -ixxFromIxS = unsafeCoerce -- TODO: switch to coerce once newtypes overhauled +ixxFromIxS = coerce {-# INLINEABLE ixsFromLinear #-} ixsFromLinear :: Num i => ShS sh -> Int -> IxS sh i ixsFromLinear (ShS sh) i = ixsFromIxX $ ixxFromLinear sh i ixsFromIxX :: IxX (MapJust sh) i -> IxS sh i -ixsFromIxX = unsafeCoerce -- TODO: switch to coerce once newtypes overhauled +ixsFromIxX = coerce shsEnum :: ShS sh -> [IIxS sh] shsEnum = shsEnum' {-# INLINABLE shsEnum' #-} -- ensure this can be specialised at use site shsEnum' :: Num i => ShS sh -> [IxS sh i] -shsEnum' (ShS sh) = (unsafeCoerce :: [IxX (MapJust sh) i] -> [IxS sh i]) $ shxEnum' sh - -- TODO: switch to coerce once newtypes overhauled +shsEnum' (ShS sh) = (coerce :: [IxX (MapJust sh) i] -> [IxS sh i]) $ shxEnum' sh -- * Shaped shapes @@ -346,8 +344,7 @@ shsLength (ShS shx) = shxLength shx shsRank :: forall sh. ShS sh -> SNat (Rank sh) shsRank (ShS shx) = - gcastWith (unsafeCoerceRefl - :: Rank (MapJust sh) :~: Rank sh) $ + gcastWith (unsafeCoerceRefl :: Rank (MapJust sh) :~: Rank sh) $ shxRank shx shsSize :: ShS sh -> Int |
