aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom@tomsmeding.com>2024-04-20 23:14:11 +0200
committerTom Smeding <tom@tomsmeding.com>2024-04-20 23:14:11 +0200
commit181c02b60445310105be126fd6cc2ee9f5dc2c8a (patch)
tree829c304dce12f41cbd21355c92c93d961977f204
parent2f5bf6144411c9e94b1ca013c1ef549ed06a5529 (diff)
GHC 9.8 compatibility
-rw-r--r--ox-arrays.cabal2
-rw-r--r--src/Data/Array/Nested/Internal.hs25
2 files changed, 13 insertions, 14 deletions
diff --git a/ox-arrays.cabal b/ox-arrays.cabal
index db5264f..0aa7001 100644
--- a/ox-arrays.cabal
+++ b/ox-arrays.cabal
@@ -12,7 +12,7 @@ library
Data.Array.Nested.Internal
Data.INat
build-depends:
- base >=4.18,
+ base >=4.18 && <4.20,
ghc-typelits-knownnat,
-- ghc-typelits-natnormalise,
orthotope,
diff --git a/src/Data/Array/Nested/Internal.hs b/src/Data/Array/Nested/Internal.hs
index bf408e6..fadf1a7 100644
--- a/src/Data/Array/Nested/Internal.hs
+++ b/src/Data/Array/Nested/Internal.hs
@@ -608,9 +608,10 @@ instance (Elt a, KnownINat n) => Elt (Ranked n a) where
| Dict <- lemKnownReplicate (Proxy @n)
= M_Ranked (mfromList (coerce l))
+ mtoList :: forall m sh. Mixed (m : sh) (Ranked n a) -> [Mixed sh (Ranked n a)]
mtoList (M_Ranked arr)
| Dict <- lemKnownReplicate (Proxy @n)
- = coerce (mtoList arr)
+ = coerce @[Mixed sh (Mixed (Replicate n 'Nothing) a)] @[Mixed sh (Ranked n a)] (mtoList arr)
mlift :: forall sh1 sh2. KnownShapeX sh2
=> (forall sh' b. (KnownShapeX sh', Storable b) => Proxy sh' -> XArray (sh1 ++ sh') b -> XArray (sh2 ++ sh') b)
@@ -736,9 +737,10 @@ instance (Elt a, KnownShape sh) => Elt (Shaped sh a) where
| Dict <- lemKnownMapJust (Proxy @sh)
= M_Shaped (mfromList (coerce l))
+ mtoList :: forall n sh'. Mixed (n : sh') (Shaped sh a) -> [Mixed sh' (Shaped sh a)]
mtoList (M_Shaped arr)
| Dict <- lemKnownMapJust (Proxy @sh)
- = coerce (mtoList arr)
+ = coerce @[Mixed sh' (Mixed (MapJust sh) a)] @[Mixed sh' (Shaped sh a)] (mtoList arr)
mlift :: forall sh1 sh2. KnownShapeX sh2
=> (forall sh' b. (KnownShapeX sh', Storable b) => Proxy sh' -> XArray (sh1 ++ sh') b -> XArray (sh2 ++ sh') b)
@@ -819,9 +821,6 @@ instance (Elt a, KnownShape sh) => Elt (Shaped sh a) where
rewriteMixed :: sh1 :~: sh2 -> Mixed sh1 a -> Mixed sh2 a
rewriteMixed Refl x = x
-coerceMixedXArray :: Coercible (Mixed sh a) (XArray sh a) => XArray sh a -> Mixed sh a
-coerceMixedXArray = coerce
-
-- ====== API OF RANKED ARRAYS ====== --
@@ -914,14 +913,14 @@ rlift f (Ranked arr)
= Ranked (mlift f arr)
rsumOuter1 :: forall n a.
- (Storable a, Num a, KnownINat n, forall sh. Coercible (Mixed sh a) (XArray sh a))
- => Ranked (S n) a -> Ranked n a
+ (Storable a, Num a, KnownINat n)
+ => Ranked (S n) (Primitive a) -> Ranked n (Primitive a)
rsumOuter1 (Ranked arr)
| Dict <- lemKnownReplicate (Proxy @n)
= Ranked
- . coerceMixedXArray
+ . coerce @(XArray (Replicate n 'Nothing) a) @(Mixed (Replicate n 'Nothing) (Primitive a))
. X.sumOuter (() :$? SZX) (knownShapeX @(Replicate n Nothing))
- . coerce @(Mixed (Replicate (S n) Nothing) a) @(XArray (Replicate (S n) Nothing) a)
+ . coerce @(Mixed (Replicate (S n) Nothing) (Primitive a)) @(XArray (Replicate (S n) Nothing) a)
$ arr
rtranspose :: forall n a. (KnownINat n, Elt a) => [Int] -> Ranked n a -> Ranked n a
@@ -1059,14 +1058,14 @@ slift f (Shaped arr)
= Shaped (mlift f arr)
ssumOuter1 :: forall sh n a.
- (Storable a, Num a, KnownNat n, KnownShape sh, forall sh'. Coercible (Mixed sh' a) (XArray sh' a))
- => Shaped (n : sh) a -> Shaped sh a
+ (Storable a, Num a, KnownNat n, KnownShape sh)
+ => Shaped (n : sh) (Primitive a) -> Shaped sh (Primitive a)
ssumOuter1 (Shaped arr)
| Dict <- lemKnownMapJust (Proxy @sh)
= Shaped
- . coerceMixedXArray
+ . coerce @(XArray (MapJust sh) a) @(Mixed (MapJust sh) (Primitive a))
. X.sumOuter (natSing @n :$@ SZX) (knownShapeX @(MapJust sh))
- . coerce @(Mixed (Just n : MapJust sh) a) @(XArray (Just n : MapJust sh) a)
+ . coerce @(Mixed (Just n : MapJust sh) (Primitive a)) @(XArray (Just n : MapJust sh) a)
$ arr
stranspose :: forall sh a. (KnownShape sh, Elt a) => [Int] -> Shaped sh a -> Shaped sh a