From dd78e2945a67f9cd32d16560c49780ae6227eed9 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Tue, 31 Oct 2023 13:51:48 +0200 Subject: [PATCH] GHC-9.8 support --- .github/workflows/haskell-ci.yml | 41 +++++++++++++++++---------- bench/JSON.hs | 48 +++++--------------------------- cabal.project | 6 ---- rere.cabal | 19 ++++++------- 4 files changed, 42 insertions(+), 72 deletions(-) diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 5120446..17d0bd2 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.16 +# version: 0.17.20231010 # -# REGENDATA ("0.16",["github","cabal.project"]) +# REGENDATA ("0.17.20231010",["github","cabal.project"]) # name: Haskell-CI on: @@ -32,19 +32,24 @@ jobs: strategy: matrix: include: - - compiler: ghc-9.6.1 + - compiler: ghc-9.8.1 compilerKind: ghc - compilerVersion: 9.6.1 + compilerVersion: 9.8.1 setup-method: ghcup allow-failure: false - - compiler: ghc-9.4.4 + - compiler: ghc-9.6.3 compilerKind: ghc - compilerVersion: 9.4.4 + compilerVersion: 9.6.3 setup-method: ghcup allow-failure: false - - compiler: ghc-9.2.7 + - compiler: ghc-9.4.7 compilerKind: ghc - compilerVersion: 9.2.7 + compilerVersion: 9.4.7 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.2.8 + compilerKind: ghc + compilerVersion: 9.2.8 setup-method: ghcup allow-failure: false - compiler: ghc-9.0.2 @@ -120,7 +125,7 @@ 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.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup" + 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) @@ -129,7 +134,7 @@ jobs: apt-get update apt-get install -y "$HCNAME" mkdir -p "$HOME/.ghcup/bin" - curl -sL https://downloads.haskell.org/ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 > "$HOME/.ghcup/bin/ghcup" + 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 @@ -145,10 +150,12 @@ jobs: echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV" HCDIR=/opt/$HCKIND/$HCVER if [ "${{ matrix.setup-method }}" = ghcup ]; then - HC=$HOME/.ghcup/bin/$HCKIND-$HCVER + 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=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV" - echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$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 @@ -216,8 +223,8 @@ jobs: - name: install cabal-docspec run: | mkdir -p $HOME/.cabal/bin - curl -sL https://github.com/phadej/cabal-extras/releases/download/cabal-docspec-0.0.0.20230406/cabal-docspec-0.0.0.20230406-x86_64-linux.xz > cabal-docspec.xz - echo '68fa9addd5dc453d533a74a763950499d4593b1297c9a05c3ea5bd1acc04c9dd cabal-docspec.xz' | sha256sum -c - + curl -sL https://github.com/phadej/cabal-extras/releases/download/cabal-docspec-0.0.0.20230517/cabal-docspec-0.0.0.20230517-x86_64-linux.xz > cabal-docspec.xz + echo '3b31bbe463ad4d671abbc103db49628562ec48a6604cab278207b5b6acd21ed7 cabal-docspec.xz' | sha256sum -c - xz -d < cabal-docspec.xz > $HOME/.cabal/bin/cabal-docspec rm -f cabal-docspec.xz chmod a+x $HOME/.cabal/bin/cabal-docspec @@ -298,10 +305,14 @@ jobs: rm -f cabal.project.local - name: constraint set intersection run: | + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='rere +rere-intersection' all --dry-run + cabal-plan topo | sort $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='rere +rere-intersection' --dependencies-only -j2 all $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='rere +rere-intersection' all - name: constraint set no-cfg run: | + if [ $((HCNUMVER >= 70800)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='rere -rere-cfg' all --dry-run ; fi + if [ $((HCNUMVER >= 70800)) -ne 0 ] ; then cabal-plan topo | sort ; fi if [ $((HCNUMVER >= 70800)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='rere -rere-cfg' --dependencies-only -j2 all ; fi if [ $((HCNUMVER >= 70800)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='rere -rere-cfg' all ; fi - name: save cache diff --git a/bench/JSON.hs b/bench/JSON.hs index fcdaa09..498859a 100644 --- a/bench/JSON.hs +++ b/bench/JSON.hs @@ -7,19 +7,13 @@ module Main (main, jsonRE, jsonRE', jsonNames, jsonCFG, jsonDerp, derp) where import Prelude hiding (exponent) import Criterion.Main (bench, defaultMain, whnf) -import Data.Either (isRight) +import Data.Maybe (isJust) import System.Clock (Clock (Monotonic), diffTimeSpec, getTime) -import qualified Data.Aeson.Parser as A -import qualified Data.Attoparsec.ByteString as Atto -import qualified Data.ByteString as BS -import qualified Data.Set as Set -import qualified Text.Derp as D - -#ifdef MIN_VERSION_saison -import qualified Saison.Decoding.Parser as S -import qualified Saison.Decoding.Tokens as S -#endif +import qualified Data.Aeson as A +import qualified Data.ByteString as BS +import qualified Data.Set as Set +import qualified Text.Derp as D import RERE import RERE.Examples.JSON @@ -34,32 +28,7 @@ derp :: D.Parser Char () -> String -> Bool derp p s = not $ Set.null $ D.runParse p [ D.Token c [c] | c <- s] aeson :: BS.ByteString -> Bool -aeson bs = isRight (Atto.parseOnly (A.json <* Atto.endOfInput) bs) - -#ifdef MIN_VERSION_saison -saison :: BS.ByteString -> Bool -saison = go end . S.tokens where - end :: BS.ByteString -> Bool - end = BS.null . S.skipSpace - - go :: (k -> Bool) -> S.Tokens k e -> Bool - go kont (S.TkLit _ k) = kont k - go kont (S.TkText _ k) = kont k - go kont (S.TkNumber _ k) = kont k - go kont (S.TkArrayOpen arr) = goArr kont arr - go kont (S.TkRecordOpen obj) = goObj kont obj - go _ (S.TkErr _) = False - - goArr :: (k -> Bool) -> S.TkArray k e -> Bool - goArr kont (S.TkItem k) = go (goArr kont) k - goArr kont (S.TkArrayEnd k) = kont k - goArr _ (S.TkArrayErr _) = False - - goObj :: (k -> Bool) -> S.TkRecord k e -> Bool - goObj kont (S.TkPair _ k) = go (goObj kont) k - goObj kont (S.TkRecordEnd k) = kont k - goObj _ (S.TkRecordErr _) = False -#endif +aeson bs = isJust (A.decodeStrict bs :: Maybe A.Value) main :: IO () main = do @@ -90,10 +59,7 @@ main = do putStrLn "Criterion" defaultMain [ bench "aeson" $ whnf aeson bs -#ifdef MIN_VERSION_saison - , bench "saison" $ whnf saison bs -#endif - -- , bench "rere" $ whnf (matchR jsonRE) contents + , bench "rere" $ whnf (matchST jsonRE) contents ] ------------------------------------------------------------------------------- diff --git a/cabal.project b/cabal.project index 7dd8406..b7cb2bf 100644 --- a/cabal.project +++ b/cabal.project @@ -5,11 +5,5 @@ benchmarks: True constraints: rere +rere-intersection --- allow-newer: async-2.2.2:base --- allow-newer: dec-0.0.3:base --- allow-newer: fin-0.1.1:base --- allow-newer: hashable-1.3.0.0:base --- allow-newer: vec-0.3:base - package rere -- ghc-options: -Wall -Werror diff --git a/rere.cabal b/rere.cabal index 81a3790..90fb737 100644 --- a/rere.cabal +++ b/rere.cabal @@ -1,7 +1,6 @@ cabal-version: 2.2 name: rere -version: 0.2 -x-revision: 3 +version: 0.2.0.1 synopsis: Regular-expressions extended with fixpoints for context-free powers @@ -33,9 +32,10 @@ tested-with: || ==8.8.4 || ==8.10.7 || ==9.0.2 - || ==9.2.7 - || ==9.4.4 - || ==9.6.1 + || ==9.2.8 + || ==9.4.7 + || ==9.6.3 + || ==9.8.1 source-repository head type: git @@ -61,7 +61,7 @@ library -- GHC boot libraries build-depends: - , base >=4.3.0.0 && <4.19 + , base >=4.3.0.0 && <4.20 , containers ^>=0.4.0.0 || ^>=0.5.0.0 || ^>=0.6.0.1 , parsec ^>=3.1.12.0 , transformers ^>=0.3.0.0 || ^>=0.4.2.0 || ^>=0.5.2.0 || ^>=0.6.1.0 @@ -146,8 +146,7 @@ benchmark json other-modules: DerpConv ghc-options: -Wall -rtsopts build-depends: - , aeson ^>=1.4.6.0 || ^>=1.5.0.0 || ^>=2.0.0.0 || ^>=2.1.0.0 - , attoparsec + , aeson ^>=1.4.6.0 || ^>=1.5.0.0 || ^>=2.0.0.0 || ^>=2.1.0.0 || ^>=2.2.1.0 , base , bytestring , clock ^>=0.8 @@ -180,9 +179,9 @@ test-suite properties , base , containers , QuickCheck - , quickcheck-instances ^>=0.3.22 + , quickcheck-instances ^>=0.3.30 , rere - , tasty ^>=1.4.0.1 + , tasty ^>=1.4.0.1 || ^>=1.5 , tasty-quickcheck ^>=0.10.1.1 if flag(rere-intersection)