From 9b81ea658ceda8f6ac3297b9485609f56daa8e48 Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Sat, 14 Dec 2024 17:02:17 +0300 Subject: [PATCH 1/4] Add Foldable1 instance to ContVec --- fixed-vector/Data/Vector/Fixed/Cont.hs | 31 +++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/fixed-vector/Data/Vector/Fixed/Cont.hs b/fixed-vector/Data/Vector/Fixed/Cont.hs index 72108c5..48e94a7 100644 --- a/fixed-vector/Data/Vector/Fixed/Cont.hs +++ b/fixed-vector/Data/Vector/Fixed/Cont.hs @@ -126,8 +126,12 @@ import Data.Data (Data) import Data.Kind (Type) import Data.Functor.Identity (Identity(..)) import Data.Typeable (Proxy(..)) -import qualified Data.Foldable as F -import qualified Data.Traversable as T +import Data.Foldable qualified as F +import Data.Traversable qualified as T +#if MIN_VERSION_base(4,18,0) +import Data.List.NonEmpty qualified as NE +import Data.Foldable1 qualified as F1 +#endif import Unsafe.Coerce (unsafeCoerce) import GHC.TypeLits import GHC.Exts (Proxy#, proxy#) @@ -545,6 +549,28 @@ instance (ArityPeano n) => F.Foldable (ContVec n) where {-# INLINE length #-} #endif + +#if MIN_VERSION_base(4,18,0) +instance (ArityPeano n, n ~ S k) => F1.Foldable1 (ContVec n) where + fold1 = foldl1 (<>) + foldMap1 f = foldl1 (<>) . map f + foldMap1' f = foldl1' (<>) . map f + toNonEmpty v = dictionaryPred (proxy# @n) + $ head v NE.:| toList (tail v) + maximum = maximum + minimum = minimum + head = head + last = F1.last . F1.toNonEmpty + {-# INLINE fold1 #-} + {-# INLINE foldMap1 #-} + {-# INLINE foldMap1' #-} + {-# INLINE toNonEmpty #-} + {-# INLINE maximum #-} + {-# INLINE minimum #-} + {-# INLINE head #-} + {-# INLINE last #-} +#endif + instance (ArityPeano n) => T.Traversable (ContVec n) where sequence = sequence sequenceA = sequence @@ -1013,7 +1039,6 @@ head $ runContVec $ uncurryFirst pure - -- | /O(n)/ Get value at specified index. index :: ArityPeano n => Int -> ContVec n a -> a {-# INLINE index #-} From d2c9c49f3cc7ba4298b451b2f3e1b61e4964cbb2 Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Sun, 21 Dec 2025 01:11:48 +0300 Subject: [PATCH 2/4] Add instance to ViaFixed and other vector types --- fixed-vector/Data/Vector/Fixed.hs | 36 ++++++++++++++++++++++++ fixed-vector/Data/Vector/Fixed/Boxed.hs | 8 ++++++ fixed-vector/Data/Vector/Fixed/Strict.hs | 8 ++++++ 3 files changed, 52 insertions(+) diff --git a/fixed-vector/Data/Vector/Fixed.hs b/fixed-vector/Data/Vector/Fixed.hs index 5c3a4a8..e45a11b 100644 --- a/fixed-vector/Data/Vector/Fixed.hs +++ b/fixed-vector/Data/Vector/Fixed.hs @@ -199,6 +199,9 @@ import Data.Monoid (Monoid(..)) import Data.Semigroup (Semigroup(..)) import Data.Foldable qualified as F import Data.Traversable qualified as T +#if MIN_VERSION_base(4,18,0) +import Data.Foldable1 qualified as F1 +#endif import Data.Primitive.Types (Prim(..)) import Foreign.Storable (Storable(..)) import GHC.TypeLits @@ -290,6 +293,10 @@ newtype T_List a n k = T_List (VecPeano k a -> VecPeano n a) deriving via ViaFixed (VecList n) instance (Arity n) => Functor (VecList n) deriving via ViaFixed (VecList n) instance (Arity n) => Applicative (VecList n) deriving via ViaFixed (VecList n) instance (Arity n) => F.Foldable (VecList n) +#if MIN_VERSION_base(4,18,0) +deriving via ViaFixed (VecList n) + instance (Arity n, C.Peano n ~ S k) => F1.Foldable1 (VecList n) +#endif instance Arity n => T.Traversable (VecList n) where sequence = sequence @@ -316,6 +323,10 @@ deriving via ViaFixed (VecList n) a instance (Arity n, Prim a) => Prim deriving via ViaFixed (VecPeano n) instance (ArityPeano n) => Functor (VecPeano n) deriving via ViaFixed (VecPeano n) instance (ArityPeano n) => Applicative (VecPeano n) deriving via ViaFixed (VecPeano n) instance (ArityPeano n) => F.Foldable (VecPeano n) +#if MIN_VERSION_base(4,18,0) +deriving via ViaFixed (VecPeano n) + instance (ArityPeano n, n ~ S k) => F1.Foldable1 (VecPeano n) +#endif instance ArityPeano n => T.Traversable (VecPeano n) where sequence = sequence @@ -343,6 +354,11 @@ deriving via ViaFixed (VecPeano n) a instance (ArityPeano n, Prim a) => Pri newtype Only a = Only a deriving (Show,Eq,Ord,Data,Functor,F.Foldable,T.Traversable) +#if MIN_VERSION_base(4,18,0) +deriving via ViaFixed Only instance F1.Foldable1 Only +#endif + + instance Monoid a => Monoid (Only a) where mempty = Only mempty mappend = (<>) @@ -537,6 +553,26 @@ instance (forall a. Vector v a) => F.Foldable (ViaFixed v) where {-# INLINE length #-} #endif +#if MIN_VERSION_base(4,18,0) +instance (forall a. Vector v a, Dim v ~ S k) => F1.Foldable1 (ViaFixed v) where + fold1 = foldl1 (<>) + foldMap1 f = F1.foldMap1 f . cvec + foldMap1' f = F1.foldMap1' f . cvec + toNonEmpty = F1.toNonEmpty . cvec + maximum = maximum + minimum = minimum + head = head + last = F1.last . cvec + {-# INLINE fold1 #-} + {-# INLINE foldMap1 #-} + {-# INLINE foldMap1' #-} + {-# INLINE toNonEmpty #-} + {-# INLINE maximum #-} + {-# INLINE minimum #-} + {-# INLINE head #-} + {-# INLINE last #-} +#endif + ---------------------------------------------------------------- -- Patterns diff --git a/fixed-vector/Data/Vector/Fixed/Boxed.hs b/fixed-vector/Data/Vector/Fixed/Boxed.hs index b166390..5dfde5f 100644 --- a/fixed-vector/Data/Vector/Fixed/Boxed.hs +++ b/fixed-vector/Data/Vector/Fixed/Boxed.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE UndecidableInstances #-} @@ -24,6 +25,9 @@ import Data.Semigroup (Semigroup(..)) import Data.Data import Data.Primitive.Types (Prim) import qualified Data.Foldable as F +#if MIN_VERSION_base(4,18,0) +import qualified Data.Foldable1 as F1 +#endif import qualified Data.Traversable as T import Foreign.Storable (Storable) import GHC.TypeLits @@ -66,6 +70,10 @@ type instance DimM (MVec n) = Peano n deriving via ViaFixed (Vec n) instance Arity n => Functor (Vec n) deriving via ViaFixed (Vec n) instance Arity n => Applicative (Vec n) deriving via ViaFixed (Vec n) instance Arity n => F.Foldable (Vec n) +#if MIN_VERSION_base(4,18,0) +deriving via ViaFixed (Vec n) + instance (Arity n, Peano n ~ S k) => F1.Foldable1 (Vec n) +#endif instance Arity n => T.Traversable (Vec n) where sequence = sequence diff --git a/fixed-vector/Data/Vector/Fixed/Strict.hs b/fixed-vector/Data/Vector/Fixed/Strict.hs index 5035ddd..36681d3 100644 --- a/fixed-vector/Data/Vector/Fixed/Strict.hs +++ b/fixed-vector/Data/Vector/Fixed/Strict.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE UndecidableInstances #-} @@ -14,6 +15,9 @@ import Data.Semigroup (Semigroup(..)) import Data.Data import Data.Primitive.Types (Prim) import qualified Data.Foldable as F +#if MIN_VERSION_base(4,18,0) +import qualified Data.Foldable1 as F1 +#endif import qualified Data.Traversable as T import Foreign.Storable (Storable) import GHC.TypeLits @@ -56,6 +60,10 @@ type instance DimM (MVec n) = Peano n deriving via ViaFixed (Vec n) instance Arity n => Functor (Vec n) deriving via ViaFixed (Vec n) instance Arity n => Applicative (Vec n) deriving via ViaFixed (Vec n) instance Arity n => F.Foldable (Vec n) +#if MIN_VERSION_base(4,18,0) +deriving via ViaFixed (Vec n) + instance (Arity n, Peano n ~ S k) => F1.Foldable1 (Vec n) +#endif instance Arity n => T.Traversable (Vec n) where sequence = sequence From ef693f28185fff929371f844db7775209b63261d Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Mon, 22 Dec 2025 17:20:41 +0300 Subject: [PATCH 3/4] Use foldable1-classes-compat for older GHC Also update changelog and add `@since` annotation --- fixed-vector/ChangeLog.md | 6 ++++-- fixed-vector/Data/Vector/Fixed.hs | 14 ++++---------- fixed-vector/Data/Vector/Fixed/Boxed.hs | 6 +----- fixed-vector/Data/Vector/Fixed/Cont.hs | 6 +----- fixed-vector/Data/Vector/Fixed/Strict.hs | 6 +----- fixed-vector/fixed-vector.cabal | 2 ++ 6 files changed, 13 insertions(+), 27 deletions(-) diff --git a/fixed-vector/ChangeLog.md b/fixed-vector/ChangeLog.md index bf97ca3..fb847e1 100644 --- a/fixed-vector/ChangeLog.md +++ b/fixed-vector/ChangeLog.md @@ -1,7 +1,9 @@ 2.0.1.0 [XXX] ------------- -* All data types defined in library now has `Prim` instance. -* `Prim` could be derived using `ViaFixed` by deriving via mechanism. +* `Prim` could be derived using `ViaFixed` by deriving via mechanism and add + data types defined in library now has `Prim` instance. +* `Foldable1` could be derived using `ViaFixed`. All types for which it could be + defined now has it. For GHC<9.6 `foldable1-classes-compat` is used. 2.0.0.0 [2025.07.10] diff --git a/fixed-vector/Data/Vector/Fixed.hs b/fixed-vector/Data/Vector/Fixed.hs index e45a11b..a3bffd2 100644 --- a/fixed-vector/Data/Vector/Fixed.hs +++ b/fixed-vector/Data/Vector/Fixed.hs @@ -199,9 +199,7 @@ import Data.Monoid (Monoid(..)) import Data.Semigroup (Semigroup(..)) import Data.Foldable qualified as F import Data.Traversable qualified as T -#if MIN_VERSION_base(4,18,0) import Data.Foldable1 qualified as F1 -#endif import Data.Primitive.Types (Prim(..)) import Foreign.Storable (Storable(..)) import GHC.TypeLits @@ -293,10 +291,9 @@ newtype T_List a n k = T_List (VecPeano k a -> VecPeano n a) deriving via ViaFixed (VecList n) instance (Arity n) => Functor (VecList n) deriving via ViaFixed (VecList n) instance (Arity n) => Applicative (VecList n) deriving via ViaFixed (VecList n) instance (Arity n) => F.Foldable (VecList n) -#if MIN_VERSION_base(4,18,0) +-- | @since @2.0.1.0 deriving via ViaFixed (VecList n) instance (Arity n, C.Peano n ~ S k) => F1.Foldable1 (VecList n) -#endif instance Arity n => T.Traversable (VecList n) where sequence = sequence @@ -323,10 +320,9 @@ deriving via ViaFixed (VecList n) a instance (Arity n, Prim a) => Prim deriving via ViaFixed (VecPeano n) instance (ArityPeano n) => Functor (VecPeano n) deriving via ViaFixed (VecPeano n) instance (ArityPeano n) => Applicative (VecPeano n) deriving via ViaFixed (VecPeano n) instance (ArityPeano n) => F.Foldable (VecPeano n) -#if MIN_VERSION_base(4,18,0) +-- | @since @2.0.1.0 deriving via ViaFixed (VecPeano n) instance (ArityPeano n, n ~ S k) => F1.Foldable1 (VecPeano n) -#endif instance ArityPeano n => T.Traversable (VecPeano n) where sequence = sequence @@ -354,9 +350,8 @@ deriving via ViaFixed (VecPeano n) a instance (ArityPeano n, Prim a) => Pri newtype Only a = Only a deriving (Show,Eq,Ord,Data,Functor,F.Foldable,T.Traversable) -#if MIN_VERSION_base(4,18,0) +-- | @since @2.0.1.0 deriving via ViaFixed Only instance F1.Foldable1 Only -#endif instance Monoid a => Monoid (Only a) where @@ -553,7 +548,7 @@ instance (forall a. Vector v a) => F.Foldable (ViaFixed v) where {-# INLINE length #-} #endif -#if MIN_VERSION_base(4,18,0) +-- | @since @2.0.1.0 instance (forall a. Vector v a, Dim v ~ S k) => F1.Foldable1 (ViaFixed v) where fold1 = foldl1 (<>) foldMap1 f = F1.foldMap1 f . cvec @@ -571,7 +566,6 @@ instance (forall a. Vector v a, Dim v ~ S k) => F1.Foldable1 (ViaFixed v) where {-# INLINE minimum #-} {-# INLINE head #-} {-# INLINE last #-} -#endif ---------------------------------------------------------------- diff --git a/fixed-vector/Data/Vector/Fixed/Boxed.hs b/fixed-vector/Data/Vector/Fixed/Boxed.hs index 5dfde5f..25abe50 100644 --- a/fixed-vector/Data/Vector/Fixed/Boxed.hs +++ b/fixed-vector/Data/Vector/Fixed/Boxed.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE UndecidableInstances #-} @@ -25,9 +24,7 @@ import Data.Semigroup (Semigroup(..)) import Data.Data import Data.Primitive.Types (Prim) import qualified Data.Foldable as F -#if MIN_VERSION_base(4,18,0) import qualified Data.Foldable1 as F1 -#endif import qualified Data.Traversable as T import Foreign.Storable (Storable) import GHC.TypeLits @@ -70,10 +67,9 @@ type instance DimM (MVec n) = Peano n deriving via ViaFixed (Vec n) instance Arity n => Functor (Vec n) deriving via ViaFixed (Vec n) instance Arity n => Applicative (Vec n) deriving via ViaFixed (Vec n) instance Arity n => F.Foldable (Vec n) -#if MIN_VERSION_base(4,18,0) +-- | @since @2.0.1.0 deriving via ViaFixed (Vec n) instance (Arity n, Peano n ~ S k) => F1.Foldable1 (Vec n) -#endif instance Arity n => T.Traversable (Vec n) where sequence = sequence diff --git a/fixed-vector/Data/Vector/Fixed/Cont.hs b/fixed-vector/Data/Vector/Fixed/Cont.hs index 48e94a7..c5cf741 100644 --- a/fixed-vector/Data/Vector/Fixed/Cont.hs +++ b/fixed-vector/Data/Vector/Fixed/Cont.hs @@ -128,11 +128,9 @@ import Data.Functor.Identity (Identity(..)) import Data.Typeable (Proxy(..)) import Data.Foldable qualified as F import Data.Traversable qualified as T -#if MIN_VERSION_base(4,18,0) import Data.List.NonEmpty qualified as NE import Data.Foldable1 qualified as F1 -#endif -import Unsafe.Coerce (unsafeCoerce) +import Unsafe.Coerce (unsafeCoerce) import GHC.TypeLits import GHC.Exts (Proxy#, proxy#) import Prelude ( Bool(..), Int, Maybe(..), Either(..) @@ -550,7 +548,6 @@ instance (ArityPeano n) => F.Foldable (ContVec n) where #endif -#if MIN_VERSION_base(4,18,0) instance (ArityPeano n, n ~ S k) => F1.Foldable1 (ContVec n) where fold1 = foldl1 (<>) foldMap1 f = foldl1 (<>) . map f @@ -569,7 +566,6 @@ instance (ArityPeano n, n ~ S k) => F1.Foldable1 (ContVec n) where {-# INLINE minimum #-} {-# INLINE head #-} {-# INLINE last #-} -#endif instance (ArityPeano n) => T.Traversable (ContVec n) where sequence = sequence diff --git a/fixed-vector/Data/Vector/Fixed/Strict.hs b/fixed-vector/Data/Vector/Fixed/Strict.hs index 36681d3..b309400 100644 --- a/fixed-vector/Data/Vector/Fixed/Strict.hs +++ b/fixed-vector/Data/Vector/Fixed/Strict.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE UndecidableInstances #-} @@ -15,9 +14,7 @@ import Data.Semigroup (Semigroup(..)) import Data.Data import Data.Primitive.Types (Prim) import qualified Data.Foldable as F -#if MIN_VERSION_base(4,18,0) import qualified Data.Foldable1 as F1 -#endif import qualified Data.Traversable as T import Foreign.Storable (Storable) import GHC.TypeLits @@ -60,10 +57,9 @@ type instance DimM (MVec n) = Peano n deriving via ViaFixed (Vec n) instance Arity n => Functor (Vec n) deriving via ViaFixed (Vec n) instance Arity n => Applicative (Vec n) deriving via ViaFixed (Vec n) instance Arity n => F.Foldable (Vec n) -#if MIN_VERSION_base(4,18,0) +-- | @since @2.0.1.0 deriving via ViaFixed (Vec n) instance (Arity n, Peano n ~ S k) => F1.Foldable1 (Vec n) -#endif instance Arity n => T.Traversable (Vec n) where sequence = sequence diff --git a/fixed-vector/fixed-vector.cabal b/fixed-vector/fixed-vector.cabal index 3cf55d4..ec19948 100644 --- a/fixed-vector/fixed-vector.cabal +++ b/fixed-vector/fixed-vector.cabal @@ -135,6 +135,8 @@ Library Build-Depends: base >=4.14 && <5 , primitive >=0.6.2 , deepseq + if impl(ghc<9.6) + Build-Depends: foldable1-classes-compat >=0.1 Exposed-modules: -- API Data.Vector.Fixed.Cont From 5eee5a8d6c34c7c6a786b5f5ee01680949ff1b13 Mon Sep 17 00:00:00 2001 From: Alexey Khudyakov Date: Mon, 22 Dec 2025 17:36:01 +0300 Subject: [PATCH 4/4] Drop support for GHC<9.2 They refuse to compile Foldable1 instances with rather weird type errors: > Could not deduce (ArityPeano k) arising from a use of ... It's unclear why k even appears. All attempts to quick fix it failed. I don't want dig into it so it's easier to just drop support for older GHC --- .github/workflows/ci.yml | 2 -- fixed-vector/ChangeLog.md | 1 + fixed-vector/Data/Vector/Fixed.hs | 25 ++++++---------------- fixed-vector/Data/Vector/Fixed/Cont.hs | 6 +----- fixed-vector/Data/Vector/Fixed/Storable.hs | 13 ----------- fixed-vector/fixed-vector.cabal | 6 ++---- 6 files changed, 11 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1df24eb..468faf4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,8 +23,6 @@ jobs: matrix: include: # Linux - - { cabal: "3.14", os: ubuntu-latest, ghc: "8.10.7" } - - { cabal: "3.14", os: ubuntu-latest, ghc: "9.0.2" } - { cabal: "3.14", os: ubuntu-latest, ghc: "9.2.8" } - { cabal: "3.14", os: ubuntu-latest, ghc: "9.4.8" } - { cabal: "3.14", os: ubuntu-latest, ghc: "9.6.7" } diff --git a/fixed-vector/ChangeLog.md b/fixed-vector/ChangeLog.md index fb847e1..afe59f6 100644 --- a/fixed-vector/ChangeLog.md +++ b/fixed-vector/ChangeLog.md @@ -1,5 +1,6 @@ 2.0.1.0 [XXX] ------------- +* Support for GHC<9.2 dropped. * `Prim` could be derived using `ViaFixed` by deriving via mechanism and add data types defined in library now has `Prim` instance. * `Foldable1` could be derived using `ViaFixed`. All types for which it could be diff --git a/fixed-vector/Data/Vector/Fixed.hs b/fixed-vector/Data/Vector/Fixed.hs index a3bffd2..de57f0e 100644 --- a/fixed-vector/Data/Vector/Fixed.hs +++ b/fixed-vector/Data/Vector/Fixed.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE QuantifiedConstraints #-} @@ -535,6 +534,7 @@ instance (forall a. Vector v a) => F.Foldable (ViaFixed v) where toList = toList sum = sum product = foldl' (*) 0 + length = length {-# INLINE foldMap' #-} {-# INLINE foldr #-} {-# INLINE foldl #-} @@ -542,11 +542,8 @@ instance (forall a. Vector v a) => F.Foldable (ViaFixed v) where {-# INLINE toList #-} {-# INLINE sum #-} {-# INLINE product #-} --- GHC<9.2 fails to compile this -#if MIN_VERSION_base(4,16,0) - length = length - {-# INLINE length #-} -#endif + {-# INLINE length #-} + -- | @since @2.0.1.0 instance (forall a. Vector v a, Dim v ~ S k) => F1.Foldable1 (ViaFixed v) where @@ -554,10 +551,10 @@ instance (forall a. Vector v a, Dim v ~ S k) => F1.Foldable1 (ViaFixed v) where foldMap1 f = F1.foldMap1 f . cvec foldMap1' f = F1.foldMap1' f . cvec toNonEmpty = F1.toNonEmpty . cvec - maximum = maximum - minimum = minimum - head = head - last = F1.last . cvec + head = head + last = F1.last . cvec + maximum = maximum + minimum = minimum {-# INLINE fold1 #-} {-# INLINE foldMap1 #-} {-# INLINE foldMap1' #-} @@ -575,34 +572,26 @@ instance (forall a. Vector v a, Dim v ~ S k) => F1.Foldable1 (ViaFixed v) where pattern V1 :: (Vector v a, Dim v ~ C.N1) => a -> v a pattern V1 x <- (convert -> (Only x)) where V1 x = mk1 x -#if MIN_VERSION_base(4,16,0) {-# INLINE V1 #-} {-# COMPLETE V1 #-} -#endif pattern V2 :: (Vector v a, Dim v ~ C.N2) => a -> a -> v a pattern V2 x y <- (convert -> (x,y)) where V2 x y = mk2 x y -#if MIN_VERSION_base(4,16,0) {-# INLINE V2 #-} {-# COMPLETE V2 #-} -#endif pattern V3 :: (Vector v a, Dim v ~ C.N3) => a -> a -> a -> v a pattern V3 x y z <- (convert -> (x,y,z)) where V3 x y z = mk3 x y z -#if MIN_VERSION_base(4,16,0) {-# INLINE V3 #-} {-# COMPLETE V3 #-} -#endif pattern V4 :: (Vector v a, Dim v ~ C.N4) => a -> a -> a -> a -> v a pattern V4 t x y z <- (convert -> (t,x,y,z)) where V4 t x y z = mk4 t x y z -#if MIN_VERSION_base(4,16,0) {-# INLINE V4 #-} {-# COMPLETE V4 #-} -#endif -- $setup -- diff --git a/fixed-vector/Data/Vector/Fixed/Cont.hs b/fixed-vector/Data/Vector/Fixed/Cont.hs index c5cf741..3efdbcd 100644 --- a/fixed-vector/Data/Vector/Fixed/Cont.hs +++ b/fixed-vector/Data/Vector/Fixed/Cont.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE UndecidableInstances #-} @@ -534,6 +533,7 @@ instance (ArityPeano n) => F.Foldable (ContVec n) where toList = toList sum = sum product = foldl' (*) 0 + length = length {-# INLINE foldMap' #-} {-# INLINE foldr #-} {-# INLINE foldl #-} @@ -541,11 +541,7 @@ instance (ArityPeano n) => F.Foldable (ContVec n) where {-# INLINE toList #-} {-# INLINE sum #-} {-# INLINE product #-} --- GHC<9.2 fails to compile this -#if MIN_VERSION_base(4,16,0) - length = length {-# INLINE length #-} -#endif instance (ArityPeano n, n ~ S k) => F1.Foldable1 (ContVec n) where diff --git a/fixed-vector/Data/Vector/Fixed/Storable.hs b/fixed-vector/Data/Vector/Fixed/Storable.hs index 33888ae..08ee0fb 100644 --- a/fixed-vector/Data/Vector/Fixed/Storable.hs +++ b/fixed-vector/Data/Vector/Fixed/Storable.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE CPP #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE UndecidableInstances #-} @@ -35,9 +34,7 @@ import GHC.ForeignPtr ( mallocPlainForeignPtrBytes ) import GHC.Ptr ( Ptr(..) ) import GHC.Exts ( proxy# ) import GHC.TypeLits -#if MIN_VERSION_base(4,15,0) import GHC.ForeignPtr ( unsafeWithForeignPtr ) -#endif import Foreign.ForeignPtr ( ForeignPtr, withForeignPtr ) import Prelude ( Show(..),Eq(..),Ord(..),Num(..),Monad(..),IO,Int , ($),undefined,seq,pure) @@ -186,13 +183,3 @@ mallocVector :: forall a. Storable a => Int -> IO (ForeignPtr a) {-# INLINE mallocVector #-} mallocVector size = mallocPlainForeignPtrBytes (size * sizeOf (undefined :: a)) - -#if !MIN_VERSION_base(4,15,0) --- | A compatibility wrapper for 'GHC.ForeignPtr.unsafeWithForeignPtr' provided --- by GHC 9.0.1 and later. --- --- Only to be used when the continuation is known not to --- unconditionally diverge lest unsoundness can result. -unsafeWithForeignPtr :: ForeignPtr a -> (Ptr a -> IO b) -> IO b -unsafeWithForeignPtr = withForeignPtr -#endif diff --git a/fixed-vector/fixed-vector.cabal b/fixed-vector/fixed-vector.cabal index ec19948..f9ce760 100644 --- a/fixed-vector/fixed-vector.cabal +++ b/fixed-vector/fixed-vector.cabal @@ -59,9 +59,7 @@ extra-doc-files: ChangeLog.md tested-with: - GHC ==8.10.7 - || ==9.0.2 - || ==9.2.8 + GHC ==9.2.8 || ==9.4.7 || ==9.6.7 || ==9.8.4 @@ -132,7 +130,7 @@ common language Library import: language - Build-Depends: base >=4.14 && <5 + Build-Depends: base >=4.16 && <5 , primitive >=0.6.2 , deepseq if impl(ghc<9.6)