From a61b16b072a79e20f5d254392122c79753b8af17 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Wed, 1 May 2024 15:33:48 +0300 Subject: [PATCH] Drop GHC < 8.6.5 support --- .github/workflows/haskell-ci.yml | 111 ++++++++++--------------------- ChangeLog.md | 5 ++ src-ghc708/PrimOps.hs | 23 ------- src/Data/Text/Short/Internal.hs | 18 +---- text-short.cabal | 56 +++++----------- 5 files changed, 56 insertions(+), 157 deletions(-) delete mode 100644 src-ghc708/PrimOps.hs diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 31ed5ad..bf1cc4e 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -8,9 +8,9 @@ # # For more information, see https://github.com/haskell-CI/haskell-ci # -# version: 0.17.20231010 +# version: 0.19.20240501 # -# REGENDATA ("0.17.20231010",["github","cabal.project"]) +# REGENDATA ("0.19.20240501",["github","cabal.project"]) # name: Haskell-CI on: @@ -27,24 +27,24 @@ jobs: timeout-minutes: 60 container: - image: buildpack-deps:bionic + image: buildpack-deps:jammy continue-on-error: ${{ matrix.allow-failure }} strategy: matrix: include: - - compiler: ghc-9.8.1 + - compiler: ghc-9.8.2 compilerKind: ghc - compilerVersion: 9.8.1 + compilerVersion: 9.8.2 setup-method: ghcup allow-failure: false - - compiler: ghc-9.6.3 + - compiler: ghc-9.6.5 compilerKind: ghc - compilerVersion: 9.6.3 + compilerVersion: 9.6.5 setup-method: ghcup allow-failure: false - - compiler: ghc-9.4.7 + - compiler: ghc-9.4.8 compilerKind: ghc - compilerVersion: 9.4.7 + compilerVersion: 9.4.8 setup-method: ghcup allow-failure: false - compiler: ghc-9.2.8 @@ -65,37 +65,12 @@ jobs: - compiler: ghc-8.8.3 compilerKind: ghc compilerVersion: 8.8.3 - setup-method: hvr-ppa + setup-method: ghcup allow-failure: false - compiler: ghc-8.6.5 compilerKind: ghc compilerVersion: 8.6.5 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-8.4.4 - compilerKind: ghc - compilerVersion: 8.4.4 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-8.2.2 - compilerKind: ghc - compilerVersion: 8.2.2 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-8.0.2 - compilerKind: ghc - compilerVersion: 8.0.2 - setup-method: hvr-ppa - allow-failure: false - - compiler: ghc-7.10.3 - compilerKind: ghc - 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 + setup-method: ghcup allow-failure: false fail-fast: false steps: @@ -103,21 +78,12 @@ jobs: run: | apt-get update 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" - 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) - else - apt-add-repository -y 'ppa:hvr/ghc' - apt-get update - apt-get install -y "$HCNAME" - 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" - chmod a+x "$HOME/.ghcup/bin/ghcup" - "$HOME/.ghcup/bin/ghcup" install cabal 3.10.1.0 || (cat "$HOME"/.ghcup/logs/*.* && false) - fi + mkdir -p "$HOME/.ghcup/bin" + 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" config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml; + "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) + "$HOME/.ghcup/bin/ghcup" install cabal 3.10.2.0 || (cat "$HOME"/.ghcup/logs/*.* && false) env: HCKIND: ${{ matrix.compilerKind }} HCNAME: ${{ matrix.compiler }} @@ -129,22 +95,13 @@ jobs: echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" HCDIR=/opt/$HCKIND/$HCVER - if [ "${{ matrix.setup-method }}" = ghcup ]; then - HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER") - HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') - HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') - 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" - 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" - fi - + HC=$("$HOME/.ghcup/bin/ghcup" whereis ghc "$HCVER") + HCPKG=$(echo "$HC" | sed 's#ghc$#ghc-pkg#') + HADDOCK=$(echo "$HC" | sed 's#ghc$#haddock#') + echo "HC=$HC" >> "$GITHUB_ENV" + echo "HCPKG=$HCPKG" >> "$GITHUB_ENV" + echo "HADDOCK=$HADDOCK" >> "$GITHUB_ENV" + echo "CABAL=$HOME/.ghcup/bin/cabal-3.10.2.0 -vnormal+nowrap" >> "$GITHUB_ENV" 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" echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV" @@ -201,7 +158,7 @@ jobs: chmod a+x $HOME/.cabal/bin/cabal-plan cabal-plan --version - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: path: source - name: initial cabal.project for sdist @@ -225,8 +182,8 @@ jobs: touch cabal.project touch cabal.project.local echo "packages: ${PKGDIR_text_short}" >> cabal.project - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package text-short" >> cabal.project ; fi - if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi + echo "package text-short" >> cabal.project + echo " ghc-options: -Werror=missing-methods" >> cabal.project cat >> cabal.project <> cabal.project.local @@ -237,7 +194,7 @@ jobs: $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all cabal-plan - name: restore cache - uses: actions/cache/restore@v3 + uses: actions/cache/restore@v4 with: key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} path: ~/.cabal/store @@ -271,11 +228,11 @@ jobs: rm -f cabal.project.local - name: constraint set text-2 run: | - if [ $((HCNUMVER >= 80000 && HCNUMVER < 90800)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text ^>=2' all --dry-run ; fi - if [ $((HCNUMVER >= 80000 && HCNUMVER < 90800)) -ne 0 ] ; then cabal-plan topo | sort ; fi - if [ $((HCNUMVER >= 80000 && HCNUMVER < 90800)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text ^>=2' --dependencies-only -j2 all ; fi - if [ $((HCNUMVER >= 80000 && HCNUMVER < 90800)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text ^>=2' all ; fi - if [ $((HCNUMVER >= 80000 && HCNUMVER < 90800)) -ne 0 ] ; then $CABAL v2-test $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text ^>=2' all ; fi + if [ $((HCNUMVER < 90800)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text ^>=2' all --dry-run ; fi + if [ $((HCNUMVER < 90800)) -ne 0 ] ; then cabal-plan topo | sort ; fi + if [ $((HCNUMVER < 90800)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text ^>=2' --dependencies-only -j2 all ; fi + if [ $((HCNUMVER < 90800)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text ^>=2' all ; fi + if [ $((HCNUMVER < 90800)) -ne 0 ] ; then $CABAL v2-test $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text ^>=2' all ; fi - name: constraint set text-1 run: | if [ $((HCNUMVER < 90400)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text ^>=1.2.3.0' all --dry-run ; fi @@ -291,7 +248,7 @@ jobs: if [ $((HCNUMVER < 90800)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='bytestring ==0.11.*' all ; fi if [ $((HCNUMVER < 90800)) -ne 0 ] ; then $CABAL v2-test $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='bytestring ==0.11.*' all ; fi - name: save cache - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 if: always() with: key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} diff --git a/ChangeLog.md b/ChangeLog.md index 9c3d0e7..0756bc3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,3 +1,8 @@ +## 0.1.6 + + * Drop support for GHC prior 8.6.5 + * Support GHC-9.10 (base-4.21) + ## 0.1.5 * text-2.0 support diff --git a/src-ghc708/PrimOps.hs b/src-ghc708/PrimOps.hs deleted file mode 100644 index 601bc07..0000000 --- a/src-ghc708/PrimOps.hs +++ /dev/null @@ -1,23 +0,0 @@ -{-# LANGUAGE MagicHash #-} -{-# LANGUAGE UnliftedFFITypes #-} -{-# LANGUAGE Unsafe #-} - -module PrimOps ( compareByteArrays# ) where - -import Foreign.C.Types (CInt (..), CSize (..)) -import GHC.Exts (Int (I#)) -import GHC.Exts (ByteArray#, Int#) -import System.IO.Unsafe (unsafeDupablePerformIO) - --- | Emulate GHC 8.4's 'GHC.Prim.compareByteArrays#' -compareByteArrays# :: ByteArray# -> Int# -> ByteArray# -> Int# -> Int# -> Int# -compareByteArrays# ba1# ofs1# ba2# ofs2# n# - = unI (fromIntegral (unsafeDupablePerformIO (c_memcmp ba1# ofs1 ba2# ofs2 n))) - where - unI (I# i#) = i# - ofs1 = fromIntegral (I# ofs1#) - ofs2 = fromIntegral (I# ofs2#) - n = fromIntegral (I# n#) - -foreign import ccall unsafe "hs_text_short_memcmp" - c_memcmp :: ByteArray# -> CSize -> ByteArray# -> CSize -> CSize -> IO CInt diff --git a/src/Data/Text/Short/Internal.hs b/src/Data/Text/Short/Internal.hs index ea7632a..34211f1 100644 --- a/src/Data/Text/Short/Internal.hs +++ b/src/Data/Text/Short/Internal.hs @@ -4,18 +4,13 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MagicHash #-} {-# LANGUAGE RankNTypes #-} +{-# LANGUAGE TemplateHaskellQuotes #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UnboxedTuples #-} {-# LANGUAGE UnliftedFFITypes #-} {-# LANGUAGE Unsafe #-} {-# LANGUAGE ViewPatterns #-} -#if __GLASGOW_HASKELL__ >= 800 -{-# LANGUAGE TemplateHaskellQuotes #-} -#else -{-# LANGUAGE TemplateHaskell #-} -#endif - -- | -- Module : Data.Text.Short.Internal -- Copyright : © Herbert Valerio Riedel 2017 @@ -238,7 +233,6 @@ instance PrintfArg ShortText where formatArg txt = formatString $ toString txt -- | The 'Binary' encoding matches the one for 'T.Text' -#if MIN_VERSION_binary(0,8,1) instance Binary ShortText where put = put . toShortByteString get = do @@ -246,16 +240,6 @@ instance Binary ShortText where case fromShortByteString sbs of Nothing -> fail "Binary.get(ShortText): Invalid UTF-8 stream" Just st -> return st -#else --- fallback via 'ByteString' instance -instance Binary ShortText where - put = put . toByteString - get = do - bs <- get - case fromByteString bs of - Nothing -> fail "Binary.get(ShortText): Invalid UTF-8 stream" - Just st -> return st -#endif -- | Since 0.1.3 instance TH.Lift ShortText where diff --git a/text-short.cabal b/text-short.cabal index cdd4c34..a6181ba 100644 --- a/text-short.cabal +++ b/text-short.cabal @@ -1,6 +1,6 @@ cabal-version: 1.18 name: text-short -version: 0.1.5.1 +version: 0.1.6 synopsis: Memory-efficient representation of Unicode text strings license: BSD3 license-file: LICENSE @@ -15,19 +15,14 @@ description: The main difference between 'Text' and 'ShortText' is that 'ShortText' doesn't support zero-copy slicing (thereby saving 2 words), and, compared to text-1.*, that it uses UTF-8 instead of UTF-16 internally. Consequently, the memory footprint of a (boxed) 'ShortText' value is 4 words (2 words when unboxed) plus the length of the UTF-8 encoded payload. tested-with: - GHC ==7.8.4 - || ==7.10.3 - || ==8.0.2 - || ==8.2.2 - || ==8.4.4 - || ==8.6.5 + GHC ==8.6.5 || ==8.8.3 || ==8.10.7 || ==9.0.2 || ==9.2.8 - || ==9.4.7 - || ==9.6.3 - || ==9.8.1 + || ==9.4.8 + || ==9.6.5 + || ==9.8.2 extra-source-files: ChangeLog.md @@ -48,46 +43,27 @@ library other-modules: Data.Text.Short.Internal build-depends: - base >=4.7 && <4.20 - , binary >=0.7.1 && <0.9 - , bytestring >=0.10.4 && <0.13 - , deepseq >=1.3 && <1.6 - , ghc-prim >=0.3.1 && <0.12 - , hashable >=1.2.6 && <1.5 - , template-haskell >=2.9.0.0 && <2.22 - , text >=1.0 && <1.3 || >=2.0 && <2.2 - - if impl(ghc >=8.0) - build-depends: bytestring >=0.10.8.0 - - if !impl(ghc >=8.0) - build-depends: semigroups >=0.18.2 && <0.21 - - -- GHC version specific PrimOps - if impl(ghc >=8.4) - hs-source-dirs: src-ghc804 - - else - c-sources: cbits/memcmp.c - hs-source-dirs: src-ghc708 + base >=4.12 && <4.20 + , binary >=0.8.6.0 && <0.9 + , bytestring >=0.10.8.2 && <0.13 + , deepseq >=1.4.4.0 && <1.6 + , ghc-prim >=0.5.3 && <0.12 + , hashable >=1.4.4.0 && <1.5 + , template-haskell >=2.14.0.0 && <2.22 + , text >=1.2.3.1 && <1.3 || >=2.0 && <2.2 other-modules: PrimOps - hs-source-dirs: src + hs-source-dirs: src src-ghc804 default-language: Haskell2010 other-extensions: CPP GeneralizedNewtypeDeriving MagicHash + TemplateHaskellQuotes Trustworthy UnliftedFFITypes Unsafe - if impl(ghc >=8) - other-extensions: TemplateHaskellQuotes - - else - other-extensions: TemplateHaskell - c-sources: cbits/cbits.c if flag(asserts) @@ -99,7 +75,7 @@ library ghc-options: -Wall cc-options: -Wall -test-suite tests +test-suite text-short-tests type: exitcode-stdio-1.0 hs-source-dirs: src-test main-is: Tests.hs