diff options
Diffstat (limited to 'src/Data/Array/Nested/Shaped/Shape.hs')
| -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 |
