Skip to content

Commit

Permalink
Drop 7x (#265)
Browse files Browse the repository at this point in the history
* Drop support for GHC versions before 8.0, base 4.9

Also shed much CPP baggage and a no longer needed FFI helper.

* Drop redundant CI jobs

* Restore cabal file

Co-authored-by: Viktor Dukhovni <[email protected]>
Co-authored-by: Bodigrim <[email protected]>
  • Loading branch information
3 people authored Feb 22, 2021
1 parent d52d42d commit 784cdd7
Show file tree
Hide file tree
Showing 24 changed files with 38 additions and 498 deletions.
37 changes: 1 addition & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,47 +11,13 @@ defaults:
shell: bash

jobs:
build-old:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
ghc: ['7.0.4', '7.2.2', '7.4.2', '7.6.3', '7.8.4']
steps:
- uses: actions/checkout@v2
- name: Update cabal package database
run: cabal update
- uses: actions/[email protected]
name: Cache cabal stuff
with:
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}
- name: Install GHC
run: |
sudo add-apt-repository ppa:hvr/ghc -y
sudo apt-get update
sudo apt-get install ghc-${{ matrix.ghc }}
- name: Test
run: |
cabal sdist -z -o .
cabal get bytestring-*.tar.gz
cd bytestring-*/
cp ../cabal.project .
cabal test -w /opt/ghc/bin/ghc-${{ matrix.ghc }} --test-show-details=direct
- name: Haddock
run: cabal haddock -w /opt/ghc/bin/ghc-${{ matrix.ghc }}

build:
needs: build-old
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
ghc: ['7.10', '8.0', '8.2', '8.4', '8.6', '8.8', '8.10', '9.0']
ghc: ['8.0', '8.2', '8.4', '8.6', '8.8', '8.10', '9.0']
include:
- os: windows-latest
ghc: 'latest'
Expand Down Expand Up @@ -89,7 +55,6 @@ jobs:
run: cabal haddock

build-freebsd:
needs: build
# This job intentionally is using macOS because at the time of the writing
# Linux and Windows environments don't have the necessary virtualization features.
# See https://github.com/vmactions/freebsd-vm#under-the-hood.
Expand Down
94 changes: 0 additions & 94 deletions Data/ByteString.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE TupleSections #-}
{-# OPTIONS_HADDOCK prune #-}
#if __GLASGOW_HASKELL__ >= 701
{-# LANGUAGE Trustworthy #-}
#endif

-- |
-- Module : Data.ByteString
Expand Down Expand Up @@ -222,16 +219,9 @@ import Prelude hiding (reverse,head,tail,last,init,null
,readFile,writeFile,appendFile,replicate
,getContents,getLine,putStr,putStrLn,interact
,zip,zipWith,unzip,notElem
#if !MIN_VERSION_base(4,6,0)
,catch
#endif
)

#if MIN_VERSION_base(4,7,0)
import Data.Bits (finiteBitSize, shiftL, (.|.), (.&.))
#else
import Data.Bits (bitSize, shiftL, (.|.), (.&.))
#endif

import Data.ByteString.Internal
import Data.ByteString.Lazy.Internal (fromStrict, toStrict)
Expand All @@ -247,11 +237,7 @@ import Control.Monad (when, void)
import Foreign.C.String (CString, CStringLen)
import Foreign.C.Types (CSize)
import Foreign.ForeignPtr (ForeignPtr, withForeignPtr, touchForeignPtr)
#if MIN_VERSION_base(4,5,0)
import Foreign.ForeignPtr.Unsafe(unsafeForeignPtrToPtr)
#else
import Foreign.ForeignPtr (unsafeForeignPtrToPtr)
#endif
import Foreign.Marshal.Alloc (allocaBytes)
import Foreign.Marshal.Array (allocaArray)
import Foreign.Ptr
Expand All @@ -264,11 +250,6 @@ import System.IO (stdin,stdout,hClose,hFileSize
,IOMode(..),hGetBufSome)
import System.IO.Error (mkIOError, illegalOperationErrorType)

#if !(MIN_VERSION_base(4,8,0))
import Control.Applicative ((<$>))
import Data.Monoid (Monoid(..))
#endif

import Data.IORef
import GHC.IO.Handle.Internals
import GHC.IO.Handle.Types
Expand All @@ -281,10 +262,6 @@ import Foreign.Marshal.Utils (copyBytes)
import GHC.Base (build)
import GHC.Word hiding (Word8)

#if !(MIN_VERSION_base(4,7,0))
finiteBitSize = bitSize
#endif

-- -----------------------------------------------------------------------------
-- Introducing and eliminating 'ByteString's

Expand Down Expand Up @@ -604,21 +581,12 @@ any f (BS x len) = accursedUnutterablePerformIO $ unsafeWithForeignPtr x g
else go (p `plusPtr` 1)
{-# INLINE [1] any #-}

#if MIN_VERSION_base(4,9,0)
{-# RULES
"ByteString specialise any (x ==)" forall x.
any (x `eqWord8`) = anyByte x
"ByteString specialise any (== x)" forall x.
any (`eqWord8` x) = anyByte x
#-}
#else
{-# RULES
"ByteString specialise any (x ==)" forall x.
any (x ==) = anyByte x
"ByteString specialise any (== x)" forall x.
any (== x) = anyByte x
#-}
#endif

-- | Is any element of 'ByteString' equal to c?
anyByte :: Word8 -> ByteString -> Bool
Expand All @@ -645,21 +613,12 @@ all f (BS x len) = accursedUnutterablePerformIO $ unsafeWithForeignPtr x g
else return False
{-# INLINE [1] all #-}

#if MIN_VERSION_base(4,9,0)
{-# RULES
"ByteString specialise all (x /=)" forall x.
all (x `neWord8`) = not . anyByte x
"ByteString specialise all (/= x)" forall x.
all (`neWord8` x) = not . anyByte x
#-}
#else
{-# RULES
"ByteString specialise all (x /=)" forall x.
all (x /=) = not . anyByte x
"ByteString specialise all (/= x)" forall x.
all (/= x) = not . anyByte x
#-}
#endif

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

Expand Down Expand Up @@ -950,7 +909,6 @@ takeWhile :: (Word8 -> Bool) -> ByteString -> ByteString
takeWhile f ps = unsafeTake (findIndexOrLength (not . f) ps) ps
{-# INLINE [1] takeWhile #-}

#if MIN_VERSION_base(4,9,0)
{-# RULES
"ByteString specialise takeWhile (x /=)" forall x.
takeWhile (x `neWord8`) = fst . breakByte x
Expand All @@ -961,18 +919,6 @@ takeWhile f ps = unsafeTake (findIndexOrLength (not . f) ps) ps
"ByteString specialise takeWhile (== x)" forall x.
takeWhile (`eqWord8` x) = fst . spanByte x
#-}
#else
{-# RULES
"ByteString specialise takeWhile (x /=)" forall x.
takeWhile (x /=) = fst . breakByte x
"ByteString specialise takeWhile (/= x)" forall x.
takeWhile (/= x) = fst . breakByte x
"ByteString specialise takeWhile (x ==)" forall x.
takeWhile (x ==) = fst . spanByte x
"ByteString specialise takeWhile (== x)" forall x.
takeWhile (== x) = fst . spanByte x
#-}
#endif

-- | Returns the longest (possibly empty) suffix of elements
-- satisfying the predicate.
Expand All @@ -991,7 +937,6 @@ dropWhile :: (Word8 -> Bool) -> ByteString -> ByteString
dropWhile f ps = unsafeDrop (findIndexOrLength (not . f) ps) ps
{-# INLINE [1] dropWhile #-}

#if MIN_VERSION_base(4,9,0)
{-# RULES
"ByteString specialise dropWhile (x /=)" forall x.
dropWhile (x `neWord8`) = snd . breakByte x
Expand All @@ -1002,18 +947,6 @@ dropWhile f ps = unsafeDrop (findIndexOrLength (not . f) ps) ps
"ByteString specialise dropWhile (== x)" forall x.
dropWhile (`eqWord8` x) = snd . spanByte x
#-}
#else
{-# RULES
"ByteString specialise dropWhile (x /=)" forall x.
dropWhile (x /=) = snd . breakByte x
"ByteString specialise dropWhile (/= x)" forall x.
dropWhile (/= x) = snd . breakByte x
"ByteString specialise dropWhile (x ==)" forall x.
dropWhile (x ==) = snd . spanByte x
"ByteString specialise dropWhile (== x)" forall x.
dropWhile (== x) = snd . spanByte x
#-}
#endif

-- | Similar to 'P.dropWhileEnd',
-- drops the longest (possibly empty) suffix of elements
Expand Down Expand Up @@ -1043,21 +976,12 @@ break p ps = case findIndexOrLength p ps of n -> (unsafeTake n ps, unsafeDrop n
{-# INLINE [1] break #-}

-- See bytestring #70
#if MIN_VERSION_base(4,9,0)
{-# RULES
"ByteString specialise break (x ==)" forall x.
break (x `eqWord8`) = breakByte x
"ByteString specialise break (== x)" forall x.
break (`eqWord8` x) = breakByte x
#-}
#else
{-# RULES
"ByteString specialise break (x ==)" forall x.
break (x ==) = breakByte x
"ByteString specialise break (== x)" forall x.
break (== x) = breakByte x
#-}
#endif

-- INTERNAL:

Expand Down Expand Up @@ -1111,21 +1035,12 @@ spanByte c ps@(BS x l) =
{-# INLINE spanByte #-}

-- See bytestring #70
#if MIN_VERSION_base(4,9,0)
{-# RULES
"ByteString specialise span (x ==)" forall x.
span (x `eqWord8`) = spanByte x
"ByteString specialise span (== x)" forall x.
span (`eqWord8` x) = spanByte x
#-}
#else
{-# RULES
"ByteString specialise span (x ==)" forall x.
span (x ==) = spanByte x
"ByteString specialise span (== x)" forall x.
span (== x) = spanByte x
#-}
#endif

-- | Returns the longest (possibly empty) suffix of elements
-- satisfying the predicate and the remainder of the string.
Expand Down Expand Up @@ -1387,21 +1302,12 @@ findIndices p = loop 0
{-# INLINE [1] findIndices #-}


#if MIN_VERSION_base(4,9,0)
{-# RULES
"ByteString specialise findIndex (x ==)" forall x. findIndex (x`eqWord8`) = elemIndex x
"ByteString specialise findIndex (== x)" forall x. findIndex (`eqWord8`x) = elemIndex x
"ByteString specialise findIndices (x ==)" forall x. findIndices (x`eqWord8`) = elemIndices x
"ByteString specialise findIndices (== x)" forall x. findIndices (`eqWord8`x) = elemIndices x
#-}
#else
{-# RULES
"ByteString specialise findIndex (x ==)" forall x. findIndex (x==) = elemIndex x
"ByteString specialise findIndex (== x)" forall x. findIndex (==x) = elemIndex x
"ByteString specialise findIndices (x ==)" forall x. findIndices (x==) = elemIndices x
"ByteString specialise findIndices (== x)" forall x. findIndices (==x) = elemIndices x
#-}
#endif

-- ---------------------------------------------------------------------
-- Searching ByteStrings
Expand Down
7 changes: 3 additions & 4 deletions Data/ByteString/Builder.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{-# LANGUAGE CPP, MagicHash #-}
{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-orphans #-}
#if __GLASGOW_HASKELL__ >= 701
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE Trustworthy #-}
#endif
{-# OPTIONS_GHC -fno-warn-unused-imports -fno-warn-orphans #-}
{- | Copyright : (c) 2010 Jasper Van der Jeugt
(c) 2010 - 2011 Simon Meier
License : BSD3-style (see LICENSE)
Expand Down
10 changes: 0 additions & 10 deletions Data/ByteString/Builder/ASCII.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{-# LANGUAGE ScopedTypeVariables, CPP, ForeignFunctionInterface,
MagicHash, UnboxedTuples #-}
{-# OPTIONS_HADDOCK not-home #-}
#if __GLASGOW_HASKELL__ >= 701
{-# LANGUAGE Trustworthy #-}
#endif
-- | Copyright : (c) 2010 - 2011 Simon Meier
-- License : BSD3-style (see LICENSE)
--
Expand Down Expand Up @@ -96,14 +94,6 @@ import GHC.Num.Integer
#define HAS_INTEGER_CONSTR 1
#define IS S#

# if !(MIN_VERSION_base(4,8,0))
import Data.Monoid (mappend)
# endif

# if __GLASGOW_HASKELL__ < 710
import GHC.Num (quotRemInteger)
# endif

import GHC.Integer.GMP.Internals
#endif

Expand Down
3 changes: 0 additions & 3 deletions Data/ByteString/Builder/Extra.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE BangPatterns #-}
#if __GLASGOW_HASKELL__ >= 701
{-# LANGUAGE Trustworthy #-}
#endif
-----------------------------------------------------------------------------
-- | Copyright : (c) 2010 Jasper Van der Jeugt
-- (c) 2010-2011 Simon Meier
Expand Down
27 changes: 1 addition & 26 deletions Data/ByteString/Builder/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{-# LANGUAGE ScopedTypeVariables, CPP, BangPatterns, RankNTypes, TupleSections #-}
#if __GLASGOW_HASKELL__ == 700
-- This is needed as a workaround for an old bug in GHC 7.0.1 (Trac #4498)
{-# LANGUAGE MonoPatBinds #-}
#endif
#if __GLASGOW_HASKELL__ >= 703
{-# LANGUAGE Unsafe #-}
#endif
{-# OPTIONS_HADDOCK not-home #-}
-- | Copyright : (c) 2010 - 2011 Simon Meier
-- License : BSD3-style (see LICENSE)
Expand Down Expand Up @@ -134,13 +128,9 @@ module Data.ByteString.Builder.Internal (

import Control.Arrow (second)

#if !(MIN_VERSION_base(4,11,0)) && MIN_VERSION_base(4,9,0)
#if !(MIN_VERSION_base(4,11,0))
import Data.Semigroup (Semigroup((<>)))
#endif
#if !(MIN_VERSION_base(4,8,0))
import Data.Monoid
import Control.Applicative (Applicative(..),(<$>))
#endif

import qualified Data.ByteString as S
import qualified Data.ByteString.Internal as S
Expand All @@ -153,18 +143,9 @@ import GHC.IO.Handle.Types (Handle__, haByteBuffer, haBufferMode)
import System.IO (hFlush, BufferMode(..), Handle)
import Data.IORef

#if MIN_VERSION_base(4,4,0)
#if MIN_VERSION_base(4,7,0)
import Foreign
#else
import Foreign hiding (unsafeForeignPtrToPtr)
#endif
import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
import System.IO.Unsafe (unsafeDupablePerformIO)
#else
import Foreign
import GHC.IO (unsafeDupablePerformIO)
#endif

------------------------------------------------------------------------------
-- Buffers
Expand Down Expand Up @@ -401,21 +382,15 @@ empty = Builder ($)
append :: Builder -> Builder -> Builder
append (Builder b1) (Builder b2) = Builder $ b1 . b2

#if MIN_VERSION_base(4,9,0)
instance Semigroup Builder where
{-# INLINE (<>) #-}
(<>) = append
#endif

instance Monoid Builder where
{-# INLINE mempty #-}
mempty = empty
{-# INLINE mappend #-}
#if MIN_VERSION_base(4,9,0)
mappend = (<>)
#else
mappend = append
#endif
{-# INLINE mconcat #-}
mconcat = foldr mappend mempty

Expand Down
Loading

0 comments on commit 784cdd7

Please sign in to comment.