From 88b326e62806a79f61b16649fa0df1dc7a17ff83 Mon Sep 17 00:00:00 2001 From: Dmitry Olshansky Date: Sat, 8 Jun 2024 17:59:37 +0300 Subject: [PATCH] build with 9.10.1. Clean warnings and upd CI --- .github/workflows/haskell.yml | 69 ++++++++++++++++++--------- patch.cabal | 12 ++--- src/Data/Patch.hs | 4 +- src/Data/Patch/MapWithPatchingMove.hs | 3 +- 4 files changed, 57 insertions(+), 31 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 31bffbf..bb91bad 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -7,38 +7,61 @@ jobs: strategy: fail-fast: false matrix: - ghc: ['8.4.4', '8.6.5', '8.8.4', '8.10.7', '9.0.1', '9.2.5', '9.4.5', '9.6.1'] - os: ['ubuntu-latest', 'macos-latest'] + ghc: ['8.6', '8.10', '9.4', '9.6', '9.8', '9.10'] + os: ['ubuntu-latest'] + include: + - ghc: '9.10' + os: 'macos-latest' runs-on: ${{ matrix.os }} name: GHC ${{ matrix.ghc }} on ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - - uses: haskell/actions/setup@v2 + - uses: actions/checkout@v4 + + - name: Set up GHC ${{ matrix.ghc-version }} + uses: haskell-actions/setup@v2 + id: setup with: ghc-version: ${{ matrix.ghc }} - cabal-version: '3.10.1.0' - - name: Cache - uses: actions/cache@v3 + + - name: Configure the build + run: | + cabal configure --enable-tests --enable-benchmarks --enable-documentation + cabal build all --dry-run + # The last step generates dist-newstyle/cache/plan.json for the cache key. + + - name: Restore cached dependencies + uses: actions/cache/restore@v4 + id: cache env: - cache-name: cache-cabal + key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} with: - path: ~/.cabal - key: ${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} - restore-keys: | - ${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}- - ${{ runner.os }}-${{ matrix.ghc }}-build- - ${{ runner.os }}-${{ matrix.ghc }}- - ${{ runner.os }} + path: ${{ steps.setup.outputs.cabal-store }} + key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} + restore-keys: ${{ env.key }}- - name: Install dependencies - run: cabal build --only-dependencies --enable-tests --enable-benchmarks + # If we had an exact cache hit, the dependencies will be up to date. + if: steps.cache.outputs.cache-hit != 'true' + run: cabal build all --only-dependencies + + # Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail. + - name: Save cached dependencies + uses: actions/cache/save@v4 + # If we had an exact cache hit, trying to save the cache would error because of key clash. + if: steps.cache.outputs.cache-hit != 'true' + with: + path: ${{ steps.setup.outputs.cabal-store }} + key: ${{ steps.cache.outputs.cache-primary-key }} + - name: Build - run: cabal build --enable-tests --enable-benchmarks all + run: cabal build all + - name: Run tests - # We don't run hlint tests, because different versions of hlint have different suggestions, and we don't want to worry about satisfying them all. - run: cabal test --enable-tests -f-hlint all - - if: matrix.ghc != '8.4.4' - # docs aren't built on ghc 8.4.4 because some dependency docs don't build on older GHCs - name: Build Docs - run: cabal haddock + run: cabal test all + + - name: Check cabal file + run: cabal check + + - name: Build documentation + run: cabal haddock all diff --git a/patch.cabal b/patch.cabal index 6817319..5aae118 100644 --- a/patch.cabal +++ b/patch.cabal @@ -37,17 +37,17 @@ flag hlint library hs-source-dirs: src default-language: Haskell2010 - build-depends: base >= 4.9 && < 4.19 + build-depends: base >= 4.9 && < 4.21 , constraints-extras >= 0.3 && < 0.5 - , commutative-semigroups >= 0.0 && < 0.2 - , containers >= 0.6 && < 0.7 + , commutative-semigroups >= 0.0 && < 0.3 + , containers >= 0.6 && < 0.8 , dependent-map >= 0.3 && < 0.5 , dependent-sum >= 0.6 && < 0.8 - , lens >= 4.7 && < 5.3 + , lens >= 4.7 && < 5.4 , indexed-traversable >= 0.1 && < 0.2 , semigroupoids >= 4.0 && < 7 , transformers >= 0.5.6.0 && < 0.7 - , witherable >= 0.3 && < 0.5 + , witherable >= 0.3 && < 0.6 if impl(ghc < 8.6) build-depends: base-orphans >= 0.8 && < 0.9 @@ -66,7 +66,7 @@ library , Data.Semigroup.Additive ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs - default-extensions: PolyKinds + default-extensions: PolyKinds, TypeOperators if flag(split-these) build-depends: these >= 1 && <1.3 diff --git a/src/Data/Patch.hs b/src/Data/Patch.hs index 71a187d..da43b07 100644 --- a/src/Data/Patch.hs +++ b/src/Data/Patch.hs @@ -14,7 +14,9 @@ module Data.Patch ) where import Data.Semigroup.Commutative +#if !MIN_VERSION_base(4,18,0) import Control.Applicative (liftA2) +#endif import Data.Functor.Const (Const (..)) import Data.Functor.Identity import Data.Map.Monoidal (MonoidalMap) @@ -24,7 +26,7 @@ import Data.Semigroup (Semigroup (..)) #endif import GHC.Generics -import qualified Data.Semigroup.Additive as X +import qualified Data.Semigroup.Commutative as X import Data.Patch.Class as X import Data.Patch.DMap as X hiding (getDeletions) import Data.Patch.DMapWithMove as X diff --git a/src/Data/Patch/MapWithPatchingMove.hs b/src/Data/Patch/MapWithPatchingMove.hs index 78be305..2be01fe 100644 --- a/src/Data/Patch/MapWithPatchingMove.hs +++ b/src/Data/Patch/MapWithPatchingMove.hs @@ -230,8 +230,9 @@ patchThatSortsMapWith cmp m = PatchMapWithPatchingMove $ Map.fromList $ catMaybe Just (from, to) reverseMapping = Map.fromList $ catMaybes $ zipWith f unsorted sorted g (to, _) (from, _) = if to == from then Nothing else - let Just movingTo = Map.lookup from reverseMapping + let movingTo = fromMaybe err $ Map.lookup from reverseMapping in Just (to, NodeInfo (From_Move from mempty) $ Just movingTo) + err = error "IMPOSSIBLE happens in patchThatSortsMapWith" -- | Create a 'PatchMapWithPatchingMove' that, if applied to the first 'Map' provided, -- will produce a 'Map' with the same values as the second 'Map' but with the