Skip to content

Commit

Permalink
Drop support for GHC 7 and bytestring < 0.10.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasabel committed Jan 6, 2024
1 parent 206d4a5 commit 3f79249
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 166 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
5 changes: 0 additions & 5 deletions benchmarks/Benchmarks.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 0 additions & 9 deletions cabal.haskell-ci
Original file line number Diff line number Diff line change
@@ -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
Expand Down
82 changes: 23 additions & 59 deletions cassava.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -55,28 +55,20 @@ 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

----------------------------------------------------------------------------

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

This comment has been minimized.

Copy link
@phadej

phadej Apr 23, 2024

Contributor

This and PolyKinds duplicate is probably a mistake?

Harmless, but slightly ugly.

This comment has been minimized.

Copy link
@andreasabel

andreasabel Apr 23, 2024

Author Member

Ah, indeed, thanks for the alert!

Would be great to get a warning from cabal check.
Also for repetitions of extensions in other-extensions that are already in default-extensions.
(This redundancy was already there before this commit.)

DefaultSignatures
DeriveFunctor
FlexibleContexts
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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
35 changes: 0 additions & 35 deletions src/Data/Csv/Conversion.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
(
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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 #-}

Expand Down Expand Up @@ -1018,17 +991,14 @@ 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 #-}

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
Expand All @@ -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
Expand Down Expand Up @@ -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."
Expand Down
5 changes: 0 additions & 5 deletions src/Data/Csv/Incremental.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions src/Data/Csv/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 0 additions & 21 deletions src/Data/Csv/Streaming.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -110,15 +99,13 @@ 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
go z (Cons (Right x) rs) = let z' = f z x in z' `seq` go z' rs
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
Expand All @@ -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'@.
Expand Down
12 changes: 0 additions & 12 deletions src/Data/Csv/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 3f79249

Please sign in to comment.