From 3f792495c1256dc2e3a503b4c5c4518dfce9c5d8 Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Fri, 5 Jan 2024 20:19:18 +0100 Subject: [PATCH] Drop support for GHC 7 and bytestring < 0.10.4. --- CHANGES.md | 5 +++ benchmarks/Benchmarks.hs | 5 --- cabal.haskell-ci | 9 ---- cassava.cabal | 82 +++++++++++-------------------------- src/Data/Csv/Conversion.hs | 35 ---------------- src/Data/Csv/Incremental.hs | 5 --- src/Data/Csv/Parser.hs | 5 --- src/Data/Csv/Streaming.hs | 21 ---------- src/Data/Csv/Util.hs | 12 ------ tests/UnitTests.hs | 15 ------- 10 files changed, 28 insertions(+), 166 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0ad4670..4645ad6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +## Unreleased + + * Remove support for GHC 7. + * Remove cabal flag `bytestring--LT-0_10_4` and support for `bytestring < 0.10.4`. + ## Version 0.5.3.0 revision 2 * Allow `bytestring-0.12` diff --git a/benchmarks/Benchmarks.hs b/benchmarks/Benchmarks.hs index 89a5e51..27c3414 100644 --- a/benchmarks/Benchmarks.hs +++ b/benchmarks/Benchmarks.hs @@ -21,11 +21,6 @@ import qualified Data.Vector as V import Data.Csv import qualified Data.Csv.Streaming as Streaming -#if !MIN_VERSION_bytestring(0,10,0) -instance NFData (B.ByteString) where - rnf !s = () -#endif - data President = President { presidency :: !Int , president :: !Text diff --git a/cabal.haskell-ci b/cabal.haskell-ci index c160c16..9f6aab5 100644 --- a/cabal.haskell-ci +++ b/cabal.haskell-ci @@ -1,14 +1,5 @@ branches: master -constraint-set text-2.1 - ghc: >=8.2 - constraints: text ^>=2.1 - tests: True - run-tests: True - -raw-project - allow-newer: text - constraint-set containers-0.7 ghc: >=8.2 constraints: containers ^>=0.7 diff --git a/cassava.cabal b/cassava.cabal index 458efad..1be1dde 100644 --- a/cassava.cabal +++ b/cassava.cabal @@ -46,7 +46,7 @@ Extra-source-files: examples/*.hs, Tested-with: GHC == 9.8.1 GHC == 9.6.3 - GHC == 9.4.7 + GHC == 9.4.8 GHC == 9.2.8 GHC == 9.0.2 GHC == 8.10.7 @@ -55,10 +55,6 @@ Tested-with: GHC == 8.4.4 GHC == 8.2.2 GHC == 8.0.2 - -- GHC == 7.10.3 - -- GHC == 7.8.4 - -- GHC == 7.6.3 - -- GHC == 7.4.2 ---------------------------------------------------------------------------- @@ -66,17 +62,13 @@ source-repository head type: git location: https://github.com/haskell-hvr/cassava.git -flag bytestring--LT-0_10_4 - description: [bytestring](https://hackage.haskell.org/haskell/package/bytestring) < 0.10.4 - default: False - manual: False - Library default-language: Haskell2010 other-extensions: BangPatterns CPP DataKinds + DataKinds DefaultSignatures DeriveFunctor FlexibleContexts @@ -85,16 +77,12 @@ Library MultiParamTypeClasses OverloadedStrings PolyKinds + PolyKinds Rank2Types ScopedTypeVariables TypeOperators UndecidableInstances - if impl(ghc >= 8.0) - other-extensions: - DataKinds - PolyKinds - hs-source-dirs: src Exposed-modules: @@ -112,51 +100,35 @@ Library Data.Csv.Util Build-depends: - base >= 4.5 && < 5 + base >= 4.9 && < 5 , array >= 0.4 && < 0.6 , attoparsec >= 0.11.3.0 && < 0.15 - , bytestring >= 0.9.2 && < 0.13 + , bytestring >= 0.10.4 && < 0.13 , containers >= 0.4.2 && < 0.8 , deepseq >= 1.1 && < 1.6 , hashable < 1.5 , scientific >= 0.3.4.7 && < 0.4 , text < 2.2 + , text-short == 0.1.* , transformers >= 0.2 && < 0.7 , unordered-containers < 0.3 , vector >= 0.8 && < 0.14 , Only >= 0.1 && < 0.1.1 - if flag(bytestring--LT-0_10_4) - build-depends: bytestring < 0.10.4 - , bytestring-builder >= 0.10.8 && < 0.11 - else - build-depends: bytestring >= 0.10.4 - , text-short == 0.1.* - - -- GHC.Generics lived in `ghc-prim` for GHC 7.2 & GHC 7.4 only - if impl(ghc < 7.6) - build-depends: ghc-prim == 0.2.* - - -- For Numeric.Natural - if impl(ghc < 7.10) - build-depends: nats >= 1 && < 1.2 - - -- https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0#Recommendationsforforward-compatibility - if impl(ghc >= 8.0) - ghc-options: -Wcompat -Wnoncanonical-monad-instances - if impl(ghc >= 8.8) - ghc-options: -Wno-star-is-type - else - ghc-options: -Wnoncanonical-monadfail-instances + ghc-options: + -Wall + -- https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0#Recommendationsforforward-compatibility + -Wcompat + -Wnoncanonical-monad-instances + + if impl(ghc >= 8.8) + ghc-options: -Wno-star-is-type else - -- provide/emulate `Control.Monad.Fail` and `Data.Semigroups` API for pre-GHC8 - build-depends: fail == 4.9.*, semigroups >= 0.18.2 && <0.20 + ghc-options: -Wnoncanonical-monadfail-instances if impl(ghc >= 8.2) ghc-options: -Wcpp-undef - ghc-options: -Wall - ---------------------------------------------------------------------------- Test-suite unit-tests @@ -184,24 +156,16 @@ Test-suite unit-tests hs-source-dirs: tests - -- GHC.Generics lived in `ghc-prim` for GHC 7.2 & GHC 7.4 only - if impl(ghc < 7.6) - build-depends: ghc-prim == 0.2.* + ghc-options: + -Wall + -- https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0#Recommendationsforforward-compatibility + -Wcompat + -Wnoncanonical-monad-instances - -- For Numeric.Natural - if impl(ghc < 7.10) - build-depends: nats - - -- https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0#Recommendationsforforward-compatibility - if impl(ghc >= 8.0) - ghc-options: -Wcompat -Wnoncanonical-monad-instances - if impl(ghc < 8.8) - ghc-options: -Wnoncanonical-monadfail-instances + if impl(ghc >= 8.8) + ghc-options: -Wno-star-is-type else - -- provide/emulate `Control.Monad.Fail` and `Data.Semigroups` API for pre-GHC8 - build-depends: fail, semigroups + ghc-options: -Wnoncanonical-monadfail-instances if impl(ghc >= 8.2) ghc-options: -Wcpp-undef - - ghc-options: -Wall diff --git a/src/Data/Csv/Conversion.hs b/src/Data/Csv/Conversion.hs index adaad2c..2e4804b 100644 --- a/src/Data/Csv/Conversion.hs +++ b/src/Data/Csv/Conversion.hs @@ -12,19 +12,8 @@ TypeOperators, UndecidableInstances #-} - -#if __GLASGOW_HASKELL__ >= 800 {-# LANGUAGE DataKinds #-} {-# LANGUAGE PolyKinds #-} -#endif - -#if !MIN_VERSION_bytestring(0,10,4) -# define MIN_VERSION_text_short(a,b,c) 0 -#endif - -#if !defined(MIN_VERSION_text_short) -# error **INVARIANT BROKEN** Detected invalid combination of `text-short` and `bytestring` versions. Please verify the `pre-bytestring-0.10-4` flag-logic in the .cabal file wasn't elided. -#endif module Data.Csv.Conversion ( @@ -81,9 +70,7 @@ import qualified Data.Attoparsec.ByteString.Char8 as A8 import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as B8 import qualified Data.ByteString.Lazy as L -#if MIN_VERSION_bytestring(0,10,4) import qualified Data.ByteString.Short as SBS -#endif import Data.Functor.Identity import Data.List (intercalate) import Data.Hashable (Hashable) @@ -97,9 +84,7 @@ import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Data.Text.Lazy as LT import qualified Data.Text.Lazy.Encoding as LT -#if MIN_VERSION_text_short(0,1,0) import qualified Data.Text.Short as T.S -#endif import Data.Tuple.Only (Only(..)) import Data.Vector (Vector, (!)) import qualified Data.Vector as V @@ -113,25 +98,13 @@ import Prelude hiding (lookup, takeWhile) import Data.Csv.Conversion.Internal import Data.Csv.Types -#if !MIN_VERSION_base(4,8,0) -import Control.Applicative (Applicative, (<$>), (<*>), (<*), (*>), pure) -import Data.Monoid (Monoid, mappend, mempty) -import Data.Traversable (traverse) -import Data.Word (Word) -#endif - ------------------------------------------------------------------------ -- bytestring compatibility toStrict :: L.ByteString -> B.ByteString fromStrict :: B.ByteString -> L.ByteString -#if MIN_VERSION_bytestring(0,10,0) toStrict = L.toStrict fromStrict = L.fromStrict -#else -toStrict = B.concat . L.toChunks -fromStrict = L.fromChunks . (:[]) -#endif {-# INLINE toStrict #-} {-# INLINE fromStrict #-} @@ -1018,7 +991,6 @@ instance ToField L.ByteString where toField = toStrict {-# INLINE toField #-} -#if MIN_VERSION_bytestring(0,10,4) instance FromField SBS.ShortByteString where parseField = pure . SBS.toShort {-# INLINE parseField #-} @@ -1026,9 +998,7 @@ instance FromField SBS.ShortByteString where instance ToField SBS.ShortByteString where toField = SBS.fromShort {-# INLINE toField #-} -#endif -#if MIN_VERSION_text_short(0,1,0) -- | Assumes UTF-8 encoding. Fails on invalid byte sequences. -- -- @since 0.5.0.0 @@ -1042,7 +1012,6 @@ instance FromField T.S.ShortText where instance ToField T.S.ShortText where toField = T.S.toByteString {-# INLINE toField #-} -#endif -- | Assumes UTF-8 encoding. Fails on invalid byte sequences. instance FromField T.Text where @@ -1397,12 +1366,8 @@ instance GToNamedRecordHeader a => GToNamedRecordHeader (M1 C c a) -- | Instance to ensure that you cannot derive DefaultOrdered for -- constructors without selectors. -#if MIN_VERSION_base(4,9,0) instance DefaultOrdered (M1 S ('MetaSel 'Nothing srcpk srcstr decstr) a ()) => GToNamedRecordHeader (M1 S ('MetaSel 'Nothing srcpk srcstr decstr) a) -#else -instance DefaultOrdered (M1 S NoSelector a ()) => GToNamedRecordHeader (M1 S NoSelector a) -#endif where gtoNamedRecordHeader _ _ = error "You cannot derive DefaultOrdered for constructors without selectors." diff --git a/src/Data/Csv/Incremental.hs b/src/Data/Csv/Incremental.hs index a6fc94f..aaffac6 100644 --- a/src/Data/Csv/Incremental.hs +++ b/src/Data/Csv/Incremental.hs @@ -100,11 +100,6 @@ import Data.Csv.Parser import Data.Csv.Types import Data.Csv.Util (endOfLine) -#if !MIN_VERSION_base(4,8,0) -import Data.Monoid (Monoid(mappend, mempty)) -import Control.Applicative ((<*)) -#endif - -- $feed-header -- -- These functions are sometimes convenient when working with diff --git a/src/Data/Csv/Parser.hs b/src/Data/Csv/Parser.hs index d028167..93c177f 100644 --- a/src/Data/Csv/Parser.hs +++ b/src/Data/Csv/Parser.hs @@ -38,11 +38,6 @@ import Data.Word (Word8) import Data.Csv.Types import Data.Csv.Util ((<$!>), blankLine, endOfLine, liftM2', cr, newline, doubleQuote, toStrict) -#if !MIN_VERSION_base(4,8,0) -import Control.Applicative ((<$>), (*>), (<*), pure) -import Data.Monoid (mappend, mempty) -#endif - -- | Options that controls how data is decoded. These options can be -- used to e.g. decode tab-separated data instead of comma-separated -- data. diff --git a/src/Data/Csv/Streaming.hs b/src/Data/Csv/Streaming.hs index 686a81e..aa23573 100644 --- a/src/Data/Csv/Streaming.hs +++ b/src/Data/Csv/Streaming.hs @@ -42,15 +42,6 @@ import qualified Data.Csv.Incremental as I import Data.Csv.Parser import Data.Csv.Types -#if !MIN_VERSION_base(4,8,0) -import Control.Applicative ((<$>), (<*>), pure) -import Data.Traversable (Traversable(..)) -#endif - -#if !MIN_VERSION_bytestring(0,10,0) -import qualified Data.ByteString.Lazy.Internal as BL -- for constructors -#endif - -- $example -- -- A short usage example: @@ -98,9 +89,7 @@ data Records a -- | Skips records that failed to convert. instance Foldable Records where foldr = foldrRecords -#if MIN_VERSION_base(4,6,0) foldl' = foldlRecords' -#endif foldrRecords :: (a -> b -> b) -> b -> Records a -> b foldrRecords f = go @@ -110,7 +99,6 @@ foldrRecords f = go go z _ = z {-# INLINE foldrRecords #-} -#if MIN_VERSION_base(4,6,0) foldlRecords' :: (a -> b -> a) -> a -> Records b -> a foldlRecords' f = go where @@ -118,7 +106,6 @@ foldlRecords' f = go go z (Cons (Left _) rs) = go z rs go z _ = z {-# INLINE foldlRecords' #-} -#endif instance Traversable Records where traverse _ (Nil merr rest) = pure $ Nil merr rest @@ -129,15 +116,7 @@ instance Traversable Records where instance NFData a => NFData (Records a) where rnf (Cons r rs) = rnf r `seq` rnf rs -#if MIN_VERSION_bytestring(0,10,0) rnf (Nil errMsg rest) = rnf errMsg `seq` rnf rest -#else - rnf (Nil errMsg rest) = rnf errMsg `seq` rnfLazyByteString rest - -rnfLazyByteString :: BL.ByteString -> () -rnfLazyByteString BL.Empty = () -rnfLazyByteString (BL.Chunk _ b) = rnfLazyByteString b -#endif -- | Efficiently deserialize CSV records in a streaming fashion. -- Equivalent to @'decodeWith' 'defaultDecodeOptions'@. diff --git a/src/Data/Csv/Util.hs b/src/Data/Csv/Util.hs index 8bb705b..ed2ab40 100644 --- a/src/Data/Csv/Util.hs +++ b/src/Data/Csv/Util.hs @@ -18,19 +18,7 @@ import qualified Data.Attoparsec.ByteString as A import qualified Data.ByteString as B import qualified Data.Vector as V import Data.Attoparsec.ByteString (Parser) - -#if !MIN_VERSION_base(4,8,0) -import Control.Applicative ((*>)) -#endif - -#if MIN_VERSION_bytestring(0,10,0) import Data.ByteString.Lazy (toStrict) -#else -import qualified Data.ByteString.Lazy as L - -toStrict :: L.ByteString -> B.ByteString -toStrict = B.concat . L.toChunks -#endif -- | A strict version of 'Data.Functor.<$>' for monads. (<$!>) :: Monad m => (a -> b) -> m a -> m b diff --git a/tests/UnitTests.hs b/tests/UnitTests.hs index 4e625e0..cb2f8cc 100644 --- a/tests/UnitTests.hs +++ b/tests/UnitTests.hs @@ -1,10 +1,6 @@ {-# LANGUAGE CPP, DataKinds, DeriveGeneric, OverloadedStrings, ScopedTypeVariables #-} -#if __GLASGOW_HASKELL__ >= 801 {-# OPTIONS_GHC -Wno-orphans -Wno-unused-top-binds #-} -#else -{-# OPTIONS_GHC -fno-warn-orphans -fno-warn-unused-binds #-} -#endif module Main ( main @@ -34,10 +30,6 @@ import Test.Framework.Providers.QuickCheck2 as TF import Data.Csv hiding (record) import qualified Data.Csv.Streaming as S -#if !MIN_VERSION_base(4,8,0) -import Control.Applicative ((<$>), (<*>)) -#endif - ------------------------------------------------------------------------ -- Parse tests @@ -304,15 +296,8 @@ conversionTests = (roundTrip :: BL.ByteString -> Bool) , testProperty "Text" (roundTrip :: T.Text -> Bool) , testProperty "lazy Text" (roundTrip :: LT.Text -> Bool) - -#if __GLASGOW_HASKELL__ >= 800 -- Using DataKinds here to prove that our Const instance is polykinded. , testProperty "Const Char" (roundTrip :: Const Char "" -> Bool) -#else - -- For lower GHC versions, Const does not support PolyKinds. - , testProperty "Const Char" (roundTrip :: Const Char () -> Bool) -#endif - ] , testGroup "boundary" [ testProperty "Int" (boundary (undefined :: Int))