Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:odr/patch into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ericson2314 committed Sep 12, 2024
2 parents 9ec61a1 + 88b326e commit 666df7c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 22 deletions.
62 changes: 41 additions & 21 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,52 @@ jobs:

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
1 change: 1 addition & 0 deletions src/Data/Patch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import Control.Applicative (liftA2)
import Data.Semigroup (Semigroup (..))
#endif

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
Expand Down
3 changes: 2 additions & 1 deletion src/Data/Patch/MapWithPatchingMove.hs
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,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
Expand Down

0 comments on commit 666df7c

Please sign in to comment.