Skip to content

Commit

Permalink
Drop support of GHC < 7.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Jan 30, 2024
1 parent 6ed7484 commit 56d534d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 127 deletions.
45 changes: 10 additions & 35 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.17.20231010
# version: 0.17.20240109
#
# REGENDATA ("0.17.20231010",["github","zlib.cabal"])
# REGENDATA ("0.17.20240109",["github","zlib.cabal"])
#
name: Haskell-CI
on:
Expand Down Expand Up @@ -88,31 +88,6 @@ jobs:
compilerVersion: 7.10.3
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.8.4
compilerKind: ghc
compilerVersion: 7.8.4
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.6.3
compilerKind: ghc
compilerVersion: 7.6.3
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.4.2
compilerKind: ghc
compilerVersion: 7.4.2
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.2.2
compilerKind: ghc
compilerVersion: 7.2.2
setup-method: hvr-ppa
allow-failure: false
- compiler: ghc-7.0.4
compilerKind: ghc
compilerVersion: 7.0.4
setup-method: hvr-ppa
allow-failure: false
fail-fast: false
steps:
- name: apt
Expand All @@ -121,20 +96,20 @@ jobs:
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
if [ "${{ matrix.setup-method }}" = ghcup ]; then
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup"
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
apt-get update
apt-get install -y zlib1g-dev
else
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y "$HCNAME" zlib1g-dev
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.19.5/x86_64-linux-ghcup-0.1.19.5 > "$HOME/.ghcup/bin/ghcup"
curl -sL https://downloads.haskell.org/ghcup/0.1.20.0/x86_64-linux-ghcup-0.1.20.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
"$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false)
fi
env:
HCKIND: ${{ matrix.compilerKind }}
Expand All @@ -154,18 +129,18 @@ jobs:
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCPKG" >> "$GITHUB_ENV"
echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
else
HC=$HCDIR/bin/$HCKIND
echo "HC=$HC" >> "$GITHUB_ENV"
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.1.0 -vnormal+nowrap" >> "$GITHUB_ENV"
echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
fi
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
if [ $((HCNUMVER >= 70400)) -ne 0 ] ; then echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" ; else echo "ARG_TESTS=--disable-tests" >> "$GITHUB_ENV" ; fi
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV"
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -272,7 +247,7 @@ jobs:
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
- name: tests
run: |
if [ $((HCNUMVER >= 70400)) -ne 0 ] ; then $CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct ; fi
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
- name: cabal check
run: |
cd ${PKGDIR_zlib} || false
Expand Down
14 changes: 0 additions & 14 deletions Codec/Compression/Zlib/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{-# LANGUAGE CPP, RankNTypes, DeriveDataTypeable, BangPatterns #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE Trustworthy #-}
#endif
-----------------------------------------------------------------------------
-- |
-- Copyright : (c) 2006-2015 Duncan Coutts
Expand Down Expand Up @@ -81,15 +79,9 @@ import Control.Monad (when)
import Control.Exception (Exception, throw, assert)
import Control.Monad.ST.Lazy hiding (stToIO)
import Control.Monad.ST.Strict (stToIO)
#if __GLASGOW_HASKELL__ >= 702
import qualified Control.Monad.ST.Unsafe as Unsafe (unsafeIOToST)
#else
import qualified Control.Monad.ST.Strict as Unsafe (unsafeIOToST)
#endif
import Data.Typeable (Typeable)
#if __GLASGOW_HASKELL__ >= 702
import GHC.Generics (Generic)
#endif
import qualified Data.ByteString.Lazy as L
import qualified Data.ByteString.Lazy.Internal as L
import qualified Data.ByteString as S
Expand Down Expand Up @@ -124,9 +116,7 @@ data CompressParams = CompressParams {
, Ord -- ^ @since 0.7.0.0
, Show
, Typeable -- ^ @since 0.7.0.0
#if __GLASGOW_HASKELL__ >= 702
, Generic -- ^ @since 0.7.0.0
#endif
)

-- | The full set of parameters for decompression. The defaults are
Expand Down Expand Up @@ -158,9 +148,7 @@ data DecompressParams = DecompressParams {
, Ord -- ^ @since 0.7.0.0
, Show
, Typeable -- ^ @since 0.7.0.0
#if __GLASGOW_HASKELL__ >= 702
, Generic -- ^ @since 0.7.0.0
#endif
)

-- | The default set of parameters for compression. This is typically used with
Expand Down Expand Up @@ -260,9 +248,7 @@ data DecompressError =
( Eq
, Ord -- ^ @since 0.7.0.0
, Typeable
#if __GLASGOW_HASKELL__ >= 702
, Generic -- ^ @since 0.7.0.0
#endif
)

instance Show DecompressError where
Expand Down
66 changes: 1 addition & 65 deletions Codec/Compression/Zlib/Stream.hsc
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{-# LANGUAGE CPP, ForeignFunctionInterface, DeriveDataTypeable #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE DeriveGeneric #-}
#endif
#if __GLASGOW_HASKELL__ >= 706
{-# LANGUAGE CApiFFI #-}
#endif
-----------------------------------------------------------------------------
-- |
-- Copyright : (c) 2006-2015 Duncan Coutts
Expand Down Expand Up @@ -107,47 +103,29 @@ import Foreign
( Word8, Ptr, nullPtr, plusPtr, peekByteOff, pokeByteOff
, ForeignPtr, FinalizerPtr, mallocForeignPtrBytes, addForeignPtrFinalizer
, withForeignPtr, touchForeignPtr, minusPtr )
#if __GLASGOW_HASKELL__ >= 702
import Foreign.ForeignPtr.Unsafe ( unsafeForeignPtrToPtr )
import System.IO.Unsafe ( unsafePerformIO )
#else
import Foreign ( unsafeForeignPtrToPtr, unsafePerformIO )
#endif
#ifdef __GLASGOW_HASKELL__
import Foreign
( finalizeForeignPtr )
#endif
import Foreign.C
import Data.ByteString.Internal (nullForeignPtr)
import qualified Data.ByteString.Unsafe as B
import Data.ByteString (ByteString)
#if !(__GLASGOW_HASKELL__ >= 710)
import Control.Applicative (Applicative(..))
#endif
import Control.Monad (ap,liftM)
#if MIN_VERSION_base(4,9,0)
import qualified Control.Monad.Fail as Fail
#endif
#if __GLASGOW_HASKELL__ >= 702
#if __GLASGOW_HASKELL__ >= 708
import Control.Monad.ST.Strict
#else
import Control.Monad.ST.Strict hiding (unsafeIOToST)
#endif
import Control.Monad.ST.Unsafe
#else
import Control.Monad.ST.Strict
#endif
import Control.Exception (assert)
import Data.Typeable (Typeable)
#if __GLASGOW_HASKELL__ >= 702
import GHC.Generics (Generic)
#endif
#ifdef DEBUG
import System.IO (hPutStrLn, stderr)
#endif

import Prelude hiding (length)
import Prelude hiding (length, Applicative(..))

#include "zlib.h"

Expand Down Expand Up @@ -379,10 +357,6 @@ instance Monad Stream where
-- m >>= f = (m `thenZ` \a -> consistencyCheck `thenZ_` returnZ a) `thenZ` f
(>>) = (*>)

#if !MIN_VERSION_base(4,8,0)
return = pure
#endif

#if !MIN_VERSION_base(4,9,0)
fail = (finalise >>) . failZ
#elif !MIN_VERSION_base(4,13,0)
Expand Down Expand Up @@ -603,9 +577,7 @@ fromFlush Block = #{const Z_BLOCK}
--
data Format = GZip | Zlib | Raw | GZipOrZlib
deriving (Eq, Ord, Enum, Bounded, Show, Typeable
#if __GLASGOW_HASKELL__ >= 702
, Generic
#endif
)

-- | The gzip format uses a header with a checksum and some optional meta-data
Expand Down Expand Up @@ -647,9 +619,7 @@ formatSupportsDictionary _ = False
--
data Method = Deflated
deriving (Eq, Ord, Enum, Bounded, Show, Typeable
#if __GLASGOW_HASKELL__ >= 702
, Generic
#endif
)

-- | The only method supported in this version of zlib.
Expand Down Expand Up @@ -677,9 +647,7 @@ data CompressionLevel =
, Ord -- ^ @since 0.7.0.0
, Show
, Typeable
#if __GLASGOW_HASKELL__ >= 702
, Generic
#endif
)

-- | The default compression level is 6 (that is, biased towards higher
Expand Down Expand Up @@ -738,9 +706,7 @@ data WindowBits = WindowBits Int
, Ord
, Show
, Typeable
#if __GLASGOW_HASKELL__ >= 702
, Generic
#endif
)

-- | The default 'WindowBits' is 15 which is also the maximum size.
Expand Down Expand Up @@ -798,9 +764,7 @@ data MemoryLevel =
, Ord -- ^ @since 0.7.0.0
, Show
, Typeable
#if __GLASGOW_HASKELL__ >= 702
, Generic
#endif
)

-- | The default memory level. (Equivalent to @'memoryLevel' 8@)
Expand Down Expand Up @@ -850,9 +814,7 @@ data CompressionStrategy =
| Fixed
-- ^ @since 0.7.0.0
deriving (Eq, Ord, Enum, Bounded, Show, Typeable
#if __GLASGOW_HASKELL__ >= 702
, Generic
#endif
)

-- | Use this default compression strategy for normal data.
Expand Down Expand Up @@ -984,12 +946,8 @@ deflate_ flush = do
-- longer be needed, for example if an error occurs or if the stream ends.
--
finalise :: Stream ()
#ifdef __GLASGOW_HASKELL__
--TODO: finalizeForeignPtr is ghc-only
finalise = getStreamState >>= unsafeLiftIO . finalizeForeignPtr
#else
finalise = return ()
#endif

checkFormatSupported :: Format -> Stream ()
checkFormatSupported format = do
Expand Down Expand Up @@ -1032,34 +990,12 @@ newtype StreamState = StreamState (Ptr StreamState)
##define SAFTY unsafe
##endif

#if __GLASGOW_HASKELL__ >= 706
foreign import capi unsafe "zlib.h inflateInit2"
c_inflateInit2 :: StreamState -> CInt -> IO CInt

foreign import capi unsafe "zlib.h deflateInit2"
c_deflateInit2 :: StreamState
-> CInt -> CInt -> CInt -> CInt -> CInt -> IO CInt
#else
foreign import ccall unsafe "zlib.h inflateInit2_"
c_inflateInit2_ :: StreamState -> CInt -> Ptr CChar -> CInt -> IO CInt

c_inflateInit2 :: StreamState -> CInt -> IO CInt
c_inflateInit2 z n =
withCAString #{const_str ZLIB_VERSION} $ \versionStr ->
c_inflateInit2_ z n versionStr (#{const sizeof(z_stream)} :: CInt)

foreign import ccall unsafe "zlib.h deflateInit2_"
c_deflateInit2_ :: StreamState
-> CInt -> CInt -> CInt -> CInt -> CInt
-> Ptr CChar -> CInt
-> IO CInt

c_deflateInit2 :: StreamState
-> CInt -> CInt -> CInt -> CInt -> CInt -> IO CInt
c_deflateInit2 z a b c d e =
withCAString #{const_str ZLIB_VERSION} $ \versionStr ->
c_deflateInit2_ z a b c d e versionStr (#{const sizeof(z_stream)} :: CInt)
#endif

foreign import ccall SAFTY "zlib.h inflate"
c_inflate :: StreamState -> CInt -> IO CInt
Expand Down
17 changes: 4 additions & 13 deletions zlib.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ description: This package provides a pure interface for compressing and
provides access to the full zlib feature set.
build-type: Simple

tested-with: GHC == 7.0.4
, GHC == 7.2.2
, GHC == 7.4.2
, GHC == 7.6.3
, GHC == 7.8.4
, GHC == 7.10.3
tested-with: GHC == 7.10.3
, GHC == 8.0.2
, GHC == 8.2.2
, GHC == 8.4.4
Expand Down Expand Up @@ -88,15 +83,11 @@ library

other-extensions: CPP, ForeignFunctionInterface, RankNTypes, BangPatterns,
DeriveDataTypeable
if impl(ghc >= 7.2)
other-extensions: DeriveGeneric
if impl(ghc >= 7.6)
other-extensions: CApiFFI
other-extensions: DeriveGeneric
other-extensions: CApiFFI

build-depends: base >= 4.3 && < 4.20,
build-depends: base >= 4.8 && < 4.20,
bytestring >= 0.9 && < 0.13
if impl(ghc < 7.6)
build-depends: ghc-prim < 0.3

build-tools: hsc2hs >= 0.67 && < 0.69
-- GHC 7 ships hsc2hs-0.67
Expand Down

0 comments on commit 56d534d

Please sign in to comment.