From 9d643a1b96ea219658bafc47fcf40a5cd0da0e3d Mon Sep 17 00:00:00 2001 From: Li-yao Xia Date: Mon, 29 Dec 2025 19:56:41 +0100 Subject: [PATCH 1/5] Allow base 4.22 --- edison-api/EdisonAPI.cabal | 2 +- edison-core/EdisonCore.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/edison-api/EdisonAPI.cabal b/edison-api/EdisonAPI.cabal index 24ebed9..b34f492 100644 --- a/edison-api/EdisonAPI.cabal +++ b/edison-api/EdisonAPI.cabal @@ -39,7 +39,7 @@ Library Data.Edison.Seq Data.Edison.Seq.ListSeq Build-Depends: - base >= 4.12 && < 4.22 + base >= 4.12 && < 4.23 if impl(ghc < 8.0) build-depends: fail < 5 Default-Language: Haskell2010 diff --git a/edison-core/EdisonCore.cabal b/edison-core/EdisonCore.cabal index 76981c7..40fecce 100644 --- a/edison-core/EdisonCore.cabal +++ b/edison-core/EdisonCore.cabal @@ -54,7 +54,7 @@ Library Data.Edison.Seq.SimpleQueue Data.Edison.Seq.SizedSeq Build-Depends: - base >= 4.12 && < 4.22, + base >= 4.12 && < 4.23, QuickCheck >= 2.8.2 && < 3, EdisonAPI >= 1.3.3 && < 1.4, containers < 0.8, From 43259dd1d1fcecd6fd7f8ad9bbbb17bbec6afa77 Mon Sep 17 00:00:00 2001 From: Li-yao Xia Date: Mon, 29 Dec 2025 20:01:31 +0100 Subject: [PATCH 2/5] ci: Add Github Actions script --- .github/workflows/haskell-ci.yml | 267 +++++++++++++++++++++++++++++++ edison-api/EdisonAPI.cabal | 1 + edison-core/EdisonCore.cabal | 2 +- test/Edison-test.cabal | 1 + 4 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/haskell-ci.yml diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml new file mode 100644 index 0000000..74f51df --- /dev/null +++ b/.github/workflows/haskell-ci.yml @@ -0,0 +1,267 @@ +# This GitHub workflow config has been generated by a script via +# +# haskell-ci 'github' 'cabal.project' +# +# To regenerate the script (for example after adjusting tested-with) run +# +# haskell-ci regenerate +# +# For more information, see https://github.com/haskell-CI/haskell-ci +# +# version: 0.19.20251211 +# +# REGENDATA ("0.19.20251211",["github","cabal.project"]) +# +name: Haskell-CI +on: + - push + - pull_request + - merge_group +jobs: + linux: + name: Haskell-CI - Linux - ${{ matrix.compiler }} + runs-on: ubuntu-24.04 + timeout-minutes: + 60 + container: + image: buildpack-deps:jammy + continue-on-error: ${{ matrix.allow-failure }} + strategy: + matrix: + include: + - compiler: ghc-9.14.0.20251128 + compilerKind: ghc + compilerVersion: 9.14.0.20251128 + setup-method: ghcup-prerelease + allow-failure: false + - compiler: ghc-9.12.1 + compilerKind: ghc + compilerVersion: 9.12.1 + setup-method: ghcup + allow-failure: false + - compiler: ghc-9.6.7 + compilerKind: ghc + compilerVersion: 9.6.7 + setup-method: ghcup + allow-failure: false + - compiler: ghc-8.10.7 + compilerKind: ghc + compilerVersion: 8.10.7 + setup-method: ghcup + allow-failure: false + fail-fast: false + steps: + - name: apt-get install + run: | + apt-get update + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5 + - name: Install GHCup + run: | + mkdir -p "$HOME/.ghcup/bin" + curl -sL https://downloads.haskell.org/ghcup/0.1.50.1/x86_64-linux-ghcup-0.1.50.1 > "$HOME/.ghcup/bin/ghcup" + chmod a+x "$HOME/.ghcup/bin/ghcup" + - name: Install cabal-install + run: | + "$HOME/.ghcup/bin/ghcup" install cabal 3.16.0.0 || (cat "$HOME"/.ghcup/logs/*.* && false) + echo "CABAL=$HOME/.ghcup/bin/cabal-3.16.0.0 -vnormal+nowrap" >> "$GITHUB_ENV" + - name: Install GHC (GHCup) + if: matrix.setup-method == 'ghcup' + run: | + "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) + 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" + env: + HCKIND: ${{ matrix.compilerKind }} + HCNAME: ${{ matrix.compiler }} + HCVER: ${{ matrix.compilerVersion }} + - name: Install GHC (GHCup prerelease) + if: matrix.setup-method == 'ghcup-prerelease' + run: | + "$HOME/.ghcup/bin/ghcup" config add-release-channel prereleases + "$HOME/.ghcup/bin/ghcup" install ghc "$HCVER" || (cat "$HOME"/.ghcup/logs/*.* && false) + 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" + env: + HCKIND: ${{ matrix.compilerKind }} + HCNAME: ${{ matrix.compiler }} + HCVER: ${{ matrix.compilerVersion }} + - name: Set PATH and environment variables + run: | + echo "$HOME/.cabal/bin" >> $GITHUB_PATH + echo "LANG=C.UTF-8" >> "$GITHUB_ENV" + echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV" + echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$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" + echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV" + if [ $((HCNUMVER >= 91400)) -ne 0 ] ; then echo "HEADHACKAGE=true" >> "$GITHUB_ENV" ; else echo "HEADHACKAGE=false" >> "$GITHUB_ENV" ; fi + echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV" + env: + HCKIND: ${{ matrix.compilerKind }} + HCNAME: ${{ matrix.compiler }} + HCVER: ${{ matrix.compilerVersion }} + - name: env + run: | + env + - name: write cabal config + run: | + mkdir -p $CABAL_DIR + cat >> $CABAL_CONFIG <> $CABAL_CONFIG <> $CABAL_CONFIG < cabal-plan.xz + echo 'f62ccb2971567a5f638f2005ad3173dba14693a45154c1508645c52289714cb2 cabal-plan.xz' | sha256sum -c - + xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan + rm -f cabal-plan.xz + chmod a+x $HOME/.cabal/bin/cabal-plan + cabal-plan --version + - name: checkout + uses: actions/checkout@v5 + with: + path: source + - name: initial cabal.project for sdist + run: | + touch cabal.project + echo "packages: $GITHUB_WORKSPACE/source/edison-api" >> cabal.project + echo "packages: $GITHUB_WORKSPACE/source/edison-core" >> cabal.project + echo "packages: $GITHUB_WORKSPACE/source/test" >> cabal.project + cat cabal.project + - name: sdist + run: | + mkdir -p sdist + $CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist + - name: unpack + run: | + mkdir -p unpacked + find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \; + - name: generate cabal.project + run: | + PKGDIR_EdisonAPI="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/EdisonAPI-[0-9.]*')" + echo "PKGDIR_EdisonAPI=${PKGDIR_EdisonAPI}" >> "$GITHUB_ENV" + PKGDIR_EdisonCore="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/EdisonCore-[0-9.]*')" + echo "PKGDIR_EdisonCore=${PKGDIR_EdisonCore}" >> "$GITHUB_ENV" + PKGDIR_Edison_test="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/Edison-test-[0-9.]*')" + echo "PKGDIR_Edison_test=${PKGDIR_Edison_test}" >> "$GITHUB_ENV" + rm -f cabal.project cabal.project.local + touch cabal.project + touch cabal.project.local + echo "packages: ${PKGDIR_EdisonAPI}" >> cabal.project + echo "packages: ${PKGDIR_EdisonCore}" >> cabal.project + echo "packages: ${PKGDIR_Edison_test}" >> cabal.project + echo "package EdisonAPI" >> cabal.project + echo " ghc-options: -Werror=missing-methods -Werror=missing-fields" >> cabal.project + echo "package EdisonCore" >> cabal.project + echo " ghc-options: -Werror=missing-methods -Werror=missing-fields" >> cabal.project + echo "package Edison-test" >> cabal.project + echo " ghc-options: -Werror=missing-methods -Werror=missing-fields" >> cabal.project + if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo "package EdisonAPI" >> cabal.project ; fi + if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo " ghc-options: -Werror=unused-packages" >> cabal.project ; fi + if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo "package EdisonCore" >> cabal.project ; fi + if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo " ghc-options: -Werror=unused-packages" >> cabal.project ; fi + if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo "package Edison-test" >> cabal.project ; fi + if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo " ghc-options: -Werror=unused-packages" >> cabal.project ; fi + if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo "package EdisonAPI" >> cabal.project ; fi + if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo " ghc-options: -Werror=incomplete-patterns -Werror=incomplete-uni-patterns" >> cabal.project ; fi + if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo "package EdisonCore" >> cabal.project ; fi + if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo " ghc-options: -Werror=incomplete-patterns -Werror=incomplete-uni-patterns" >> cabal.project ; fi + if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo "package Edison-test" >> cabal.project ; fi + if [ $((HCNUMVER >= 90600)) -ne 0 ] ; then echo " ghc-options: -Werror=incomplete-patterns -Werror=incomplete-uni-patterns" >> cabal.project ; fi + cat >> cabal.project <> cabal.project + fi + $HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: any.$_ installed\n" unless /^(Edison-test|EdisonAPI|EdisonCore)$/; }' >> cabal.project.local + cat cabal.project + cat cabal.project.local + - name: dump install plan + run: | + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all + cabal-plan + - name: restore cache + uses: actions/cache/restore@v4 + with: + key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} + path: ~/.cabal/store + restore-keys: ${{ runner.os }}-${{ matrix.compiler }}- + - name: install dependencies + run: | + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all + - name: build w/o tests + run: | + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all + - name: build + run: | + $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always + - name: cabal check + run: | + cd ${PKGDIR_EdisonAPI} || false + ${CABAL} -vnormal check + cd ${PKGDIR_EdisonCore} || false + ${CABAL} -vnormal check + cd ${PKGDIR_Edison_test} || false + ${CABAL} -vnormal check + - name: haddock + run: | + $CABAL v2-haddock --disable-documentation --haddock-all $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all + - name: unconstrained build + run: | + rm -f cabal.project.local + $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all + - name: save cache + if: always() + uses: actions/cache/save@v4 + with: + key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }} + path: ~/.cabal/store diff --git a/edison-api/EdisonAPI.cabal b/edison-api/EdisonAPI.cabal index b34f492..f7458cd 100644 --- a/edison-api/EdisonAPI.cabal +++ b/edison-api/EdisonAPI.cabal @@ -21,6 +21,7 @@ Description: Associative Collections such as finite maps and priority queues where the priority and element are distinct. Extra-Source-Files: CHANGES.md +tested-with: GHC == 8.10.7, GHC == 9.6.7, GHC == 9.12.1, GHC == 9.14.1 Source-Repository head Type: git diff --git a/edison-core/EdisonCore.cabal b/edison-core/EdisonCore.cabal index 40fecce..43bf37e 100644 --- a/edison-core/EdisonCore.cabal +++ b/edison-core/EdisonCore.cabal @@ -17,7 +17,7 @@ Description: implementations in this package have no dependencies other than those commonly bundled with Haskell compilers. Extra-Source-Files: CHANGES.md - +tested-with: GHC == 8.10.7, GHC == 9.6.7, GHC == 9.12.1, GHC == 9.14.1 Source-Repository head Type: git diff --git a/test/Edison-test.cabal b/test/Edison-test.cabal index bd12554..752be6b 100644 --- a/test/Edison-test.cabal +++ b/test/Edison-test.cabal @@ -7,6 +7,7 @@ Maintainer: robdockins AT fastmail DOT fm Synopsis: Testsuite for Edison Category: Data structures Stability: provisional +tested-with: GHC == 8.10.7, GHC == 9.6.7, GHC == 9.12.1, GHC == 9.14.1 Source-Repository head Type: git From 52a0051dc5354702813870679a29c1a0b129b47a Mon Sep 17 00:00:00 2001 From: Li-yao Xia Date: Mon, 29 Dec 2025 20:06:27 +0100 Subject: [PATCH 3/5] Remove spurious array dependency --- edison-core/EdisonCore.cabal | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/edison-core/EdisonCore.cabal b/edison-core/EdisonCore.cabal index 43bf37e..2a4fe9f 100644 --- a/edison-core/EdisonCore.cabal +++ b/edison-core/EdisonCore.cabal @@ -57,8 +57,7 @@ Library base >= 4.12 && < 4.23, QuickCheck >= 2.8.2 && < 3, EdisonAPI >= 1.3.3 && < 1.4, - containers < 0.8, - array < 0.6 + containers < 0.8 if impl(ghc < 8.0) Build-Depends: From cf98750f6f3722bf4fe5cf19aec377ae5b6853c4 Mon Sep 17 00:00:00 2001 From: Li-yao Xia Date: Mon, 29 Dec 2025 20:34:42 +0100 Subject: [PATCH 4/5] Enable warnings --- edison-core/EdisonCore.cabal | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/edison-core/EdisonCore.cabal b/edison-core/EdisonCore.cabal index 2a4fe9f..23527ae 100644 --- a/edison-core/EdisonCore.cabal +++ b/edison-core/EdisonCore.cabal @@ -76,6 +76,6 @@ Library ScopedTypeVariables GeneralizedNewtypeDeriving FlexibleContexts - Ghc-Options: -funbox-strict-fields -fwarn-incomplete-patterns + Ghc-Options: -funbox-strict-fields -Wall -Wno-name-shadowing -Wno-noncanonical-monad-instances if impl(ghc >= 8.0) - Ghc-Options: -Wcompat + Ghc-Options: -Wcompat From ac067ec2771f165790388b2568ac8e319a963554 Mon Sep 17 00:00:00 2001 From: Li-yao Xia Date: Mon, 29 Dec 2025 20:35:16 +0100 Subject: [PATCH 5/5] Resolve warnings about partial patterns and type defaulting --- edison-core/src/Data/Edison/Assoc/AssocList.hs | 4 ++-- edison-core/src/Data/Edison/Assoc/Defaults.hs | 8 ++++++-- .../src/Data/Edison/Assoc/PatriciaLoMap.hs | 6 +++--- .../src/Data/Edison/Assoc/TernaryTrie.hs | 8 ++++---- edison-core/src/Data/Edison/Coll/Defaults.hs | 4 +++- .../src/Data/Edison/Coll/LazyPairingHeap.hs | 10 ++++++---- .../src/Data/Edison/Coll/LeftistHeap.hs | 11 ++++++----- edison-core/src/Data/Edison/Coll/MinHeap.hs | 4 ++-- edison-core/src/Data/Edison/Coll/SkewHeap.hs | 13 +++++++------ edison-core/src/Data/Edison/Coll/SplayHeap.hs | 4 ++-- .../src/Data/Edison/Coll/UnbalancedSet.hs | 11 ++++++----- .../src/Data/Edison/Concrete/FingerTree.hs | 18 +++++++++--------- .../src/Data/Edison/Seq/BinaryRandList.hs | 6 +++--- edison-core/src/Data/Edison/Seq/BraunSeq.hs | 3 --- edison-core/src/Data/Edison/Seq/Defaults.hs | 4 +++- edison-core/src/Data/Edison/Seq/JoinList.hs | 6 +++--- 16 files changed, 65 insertions(+), 55 deletions(-) diff --git a/edison-core/src/Data/Edison/Assoc/AssocList.hs b/edison-core/src/Data/Edison/Assoc/AssocList.hs index 985e927..9f01265 100644 --- a/edison-core/src/Data/Edison/Assoc/AssocList.hs +++ b/edison-core/src/Data/Edison/Assoc/AssocList.hs @@ -615,8 +615,8 @@ instance (Eq k,Arbitrary k,Arbitrary a) => Arbitrary (FM k a) where return (Prelude.foldr (uncurry insert) empty xs) instance (Eq k,CoArbitrary k,CoArbitrary a) => CoArbitrary (FM k a) where - coarbitrary E = variant 0 - coarbitrary (I k a m) = variant 1 . coarbitrary k + coarbitrary E = variant (0 :: Int) + coarbitrary (I k a m) = variant (1 :: Int) . coarbitrary k . coarbitrary a . coarbitrary m diff --git a/edison-core/src/Data/Edison/Assoc/Defaults.hs b/edison-core/src/Data/Edison/Assoc/Defaults.hs index 116b5b7..c42dd78 100644 --- a/edison-core/src/Data/Edison/Assoc/Defaults.hs +++ b/edison-core/src/Data/Edison/Assoc/Defaults.hs @@ -277,7 +277,9 @@ readsPrecUsingFromList _ xs = -- play games with the typechecker so we don't have to use -- extensions for scoped type variables - ~[(x,_)] = result + x = case result of + [(x',_)] -> x' + _ -> undefined in result @@ -295,7 +297,9 @@ readsPrecUsingUnsafeFromOrdSeq i xs = -- play games with the typechecker so we don't have to use -- extensions for scoped type variables - ~[(x,_)] = result + x = case result of + [(x',_)] -> x' + _ -> undefined in result diff --git a/edison-core/src/Data/Edison/Assoc/PatriciaLoMap.hs b/edison-core/src/Data/Edison/Assoc/PatriciaLoMap.hs index aeaa9bb..245f973 100644 --- a/edison-core/src/Data/Edison/Assoc/PatriciaLoMap.hs +++ b/edison-core/src/Data/Edison/Assoc/PatriciaLoMap.hs @@ -840,9 +840,9 @@ instance (Arbitrary a) => Arbitrary (FM a) where return (Prelude.foldr (uncurry insert) empty xs) instance (CoArbitrary a) => CoArbitrary (FM a) where - coarbitrary E = variant 0 - coarbitrary (L i a) = variant 1 . coarbitrary i . coarbitrary a - coarbitrary (B i j m n) = variant 2 . coarbitrary i . coarbitrary j + coarbitrary E = variant (0 :: Int) + coarbitrary (L i a) = variant (1 :: Int) . coarbitrary i . coarbitrary a + coarbitrary (B i j m n) = variant (2 :: Int) . coarbitrary i . coarbitrary j . coarbitrary m . coarbitrary n diff --git a/edison-core/src/Data/Edison/Assoc/TernaryTrie.hs b/edison-core/src/Data/Edison/Assoc/TernaryTrie.hs index 2a1d245..adddaa4 100644 --- a/edison-core/src/Data/Edison/Assoc/TernaryTrie.hs +++ b/edison-core/src/Data/Edison/Assoc/TernaryTrie.hs @@ -1152,13 +1152,13 @@ instance (Ord k,CoArbitrary k,CoArbitrary a) => CoArbitrary (FM k a) where coarbitrary_maybe :: (CoArbitrary t) => Maybe t -> Test.QuickCheck.Gen b -> Test.QuickCheck.Gen b -coarbitrary_maybe Nothing = variant 0 -coarbitrary_maybe (Just x) = variant 1 . coarbitrary x +coarbitrary_maybe Nothing = variant (0 :: Int) +coarbitrary_maybe (Just x) = variant (1 :: Int) . coarbitrary x coarbitrary_fmb :: (CoArbitrary t1, CoArbitrary t) => FMB t t1 -> Gen a -> Gen a -coarbitrary_fmb E = variant 0 +coarbitrary_fmb E = variant (0 :: Int) coarbitrary_fmb (I _ k x l (FMB' m) r) = - variant 1 . coarbitrary k . coarbitrary_maybe x . + variant (1 :: Int) . coarbitrary k . coarbitrary_maybe x . coarbitrary_fmb l . coarbitrary_fmb m . coarbitrary_fmb r instance Ord k => Semigroup (FM k a) where diff --git a/edison-core/src/Data/Edison/Coll/Defaults.hs b/edison-core/src/Data/Edison/Coll/Defaults.hs index 8fb8e17..8bd7dfc 100644 --- a/edison-core/src/Data/Edison/Coll/Defaults.hs +++ b/edison-core/src/Data/Edison/Coll/Defaults.hs @@ -230,7 +230,9 @@ readsPrecUsingFromList _ xs = -- play games with the typechecker so we don't have to use -- extensions for scoped type variables - ~[(x,_)] = result + x = case result of + [(x',_)] -> x' + _ -> undefined in result diff --git a/edison-core/src/Data/Edison/Coll/LazyPairingHeap.hs b/edison-core/src/Data/Edison/Coll/LazyPairingHeap.hs index 779d738..a7f26f6 100644 --- a/edison-core/src/Data/Edison/Coll/LazyPairingHeap.hs +++ b/edison-core/src/Data/Edison/Coll/LazyPairingHeap.hs @@ -534,7 +534,9 @@ instance (Ord a, Arbitrary a) => Arbitrary (Heap a) where (arbTree (n `div` 2)))] sift x E a = sift1 x a - sift x a E = let H1 x' a' = sift1 x a in H2 x' a' E + sift x a E = case sift1 x a of + H1 x' a' -> H2 x' a' E + _ -> undefined sift x a b | x <= ma && x <= mb = H2 x a b | ma < x && ma <= mb = H2 ma (siftInto x a) b @@ -553,10 +555,10 @@ instance (Ord a, Arbitrary a) => Arbitrary (Heap a) where siftInto _ E = error "LazyPairingHeap.arbitrary: bug!" instance (Ord a, CoArbitrary a) => CoArbitrary (Heap a) where - coarbitrary E = variant 0 - coarbitrary (H1 x a) = variant 1 . coarbitrary x . coarbitrary a + coarbitrary E = variant (0 :: Int) + coarbitrary (H1 x a) = variant (1 :: Int) . coarbitrary x . coarbitrary a coarbitrary (H2 x a b) = - variant 2 . coarbitrary x . coarbitrary a . coarbitrary b + variant (2 :: Int) . coarbitrary x . coarbitrary a . coarbitrary b instance (Ord a) => Semigroup (Heap a) where (<>) = union diff --git a/edison-core/src/Data/Edison/Coll/LeftistHeap.hs b/edison-core/src/Data/Edison/Coll/LeftistHeap.hs index 3b84983..4ebcd83 100644 --- a/edison-core/src/Data/Edison/Coll/LeftistHeap.hs +++ b/edison-core/src/Data/Edison/Coll/LeftistHeap.hs @@ -44,6 +44,7 @@ import qualified Data.Edison.Coll as C ( CollX(..), OrdCollX(..), Coll(..), OrdC unionList, toOrdList ) import qualified Data.Edison.Seq as S import Data.Edison.Coll.Defaults +import Data.Maybe (fromJust) import Data.Monoid import Data.Semigroup as SG import Control.Monad @@ -312,12 +313,12 @@ maxView :: (Ord a, Fail.MonadFail m) => Heap a -> m (a, Heap a) maxView E = fail "LeftistHeap.maxView: empty collection" maxView (L _ x E _) = return (x, E) maxView (L _ x a E) = return (y, L 1 x a' E) - where Just (y,a') = maxView a + where (y,a') = fromJust (maxView a) maxView (L _ x a b) | y >= z = return (y, node x a' b) | otherwise = return (z, node x a b') - where Just (y, a') = maxView a - Just (z, b') = maxView b + where (y, a') = fromJust (maxView a) + (z, b') = fromJust (maxView b) -- warning: maxView and maxElem may disagree if root is equal to max! @@ -480,9 +481,9 @@ instance (Ord a, Arbitrary a) => Arbitrary (Heap a) where sift _ = error "LeftistHeap.arbitrary: bug!" instance (Ord a, CoArbitrary a) => CoArbitrary (Heap a) where - coarbitrary E = variant 0 + coarbitrary E = variant (0 :: Int) coarbitrary (L _ x a b) = - variant 1 . coarbitrary x . coarbitrary a . coarbitrary b + variant (1 :: Int) . coarbitrary x . coarbitrary a . coarbitrary b instance (Ord a) => Semigroup (Heap a) where (<>) = union diff --git a/edison-core/src/Data/Edison/Coll/MinHeap.hs b/edison-core/src/Data/Edison/Coll/MinHeap.hs index 05a42c7..e419a28 100644 --- a/edison-core/src/Data/Edison/Coll/MinHeap.hs +++ b/edison-core/src/Data/Edison/Coll/MinHeap.hs @@ -396,8 +396,8 @@ instance (C.OrdColl h a,Arbitrary h,Arbitrary a) => Arbitrary (Min h a) where else fromPrim xs) instance (C.OrdColl h a,CoArbitrary h,CoArbitrary a) => CoArbitrary (Min h a) where - coarbitrary E = variant 0 - coarbitrary (M x xs) = variant 1 . coarbitrary x . coarbitrary xs + coarbitrary E = variant (0 :: Int) + coarbitrary (M x xs) = variant (1 :: Int) . coarbitrary x . coarbitrary xs instance (C.OrdColl h a) => SG.Semigroup (Min h a) where (<>) = union diff --git a/edison-core/src/Data/Edison/Coll/SkewHeap.hs b/edison-core/src/Data/Edison/Coll/SkewHeap.hs index a5491f1..8a82ce7 100644 --- a/edison-core/src/Data/Edison/Coll/SkewHeap.hs +++ b/edison-core/src/Data/Edison/Coll/SkewHeap.hs @@ -44,6 +44,7 @@ import Prelude hiding (null,foldr,foldl,foldr1,foldl1,foldl',lookup,filter) import qualified Data.Edison.Coll as C import qualified Data.Edison.Seq as S import Data.Edison.Coll.Defaults +import Data.Maybe (fromJust) import Data.Monoid import Data.Semigroup as SG import Control.Monad @@ -280,14 +281,14 @@ maxView :: (Ord a, Fail.MonadFail m) => Heap a -> m (a, Heap a) maxView E = fail "SkewHeap.maxView: empty heap" maxView (T x E E) = return (x, E) maxView (T x a E) = return (y, T x a' E) - where Just (y, a') = maxView a + where (y, a') = fromJust (maxView a) maxView (T x E a) = return (y, T x a' E) - where Just (y, a') = maxView a + where (y, a') = fromJust (maxView a) maxView (T x a b) | y >= z = return (y, T x a' b) | otherwise = return (z, T x a b') - where Just (y, a') = maxView a - Just (z, b') = maxView b + where (y, a') = fromJust (maxView a) + (z, b') = fromJust (maxView b) -- warning: maxView and maxElem may disagree if root is equal to max! @@ -448,9 +449,9 @@ instance (Ord a, Arbitrary a) => Arbitrary (Heap a) where sift x a b = T x a b instance (Ord a, CoArbitrary a) => CoArbitrary (Heap a) where - coarbitrary E = variant 0 + coarbitrary E = variant (0 :: Int) coarbitrary (T x a b) = - variant 1 . coarbitrary x . coarbitrary a . coarbitrary b + variant (1 :: Int) . coarbitrary x . coarbitrary a . coarbitrary b instance (Ord a) => Semigroup (Heap a) where (<>) = union diff --git a/edison-core/src/Data/Edison/Coll/SplayHeap.hs b/edison-core/src/Data/Edison/Coll/SplayHeap.hs index 4708bee..6601bb1 100644 --- a/edison-core/src/Data/Edison/Coll/SplayHeap.hs +++ b/edison-core/src/Data/Edison/Coll/SplayHeap.hs @@ -483,9 +483,9 @@ instance (Ord a,Arbitrary a) => Arbitrary (Heap a) where return (C.fromList xs) instance (Ord a,CoArbitrary a) => CoArbitrary (Heap a) where - coarbitrary E = variant 0 + coarbitrary E = variant (0 :: Int) coarbitrary (T a x b) = - variant 1 . coarbitrary a . coarbitrary x . coarbitrary b + variant (1 :: Int) . coarbitrary a . coarbitrary x . coarbitrary b instance (Ord a) => Semigroup (Heap a) where (<>) = union diff --git a/edison-core/src/Data/Edison/Coll/UnbalancedSet.hs b/edison-core/src/Data/Edison/Coll/UnbalancedSet.hs index ad21c1d..3ef580f 100644 --- a/edison-core/src/Data/Edison/Coll/UnbalancedSet.hs +++ b/edison-core/src/Data/Edison/Coll/UnbalancedSet.hs @@ -47,6 +47,7 @@ import qualified Control.Monad.Fail as Fail import qualified Data.Edison.Coll as C import qualified Data.Edison.Seq as S import Data.Edison.Coll.Defaults +import Data.Maybe (fromJust) import Data.Monoid import Data.Semigroup as SG import Test.QuickCheck @@ -214,7 +215,7 @@ unsafeFromOrdSeq xs = fst (ins xs (S.size xs)) where ins ys 0 = (E,ys) ins ys n = let m = n `div` 2 (a,ys') = ins ys m - Just (y,ys'') = S.lview ys' + (y,ys'') = fromJust (S.lview ys') (b,ys''') = ins ys'' (n - m - 1) in (T a y b,ys''') @@ -280,7 +281,7 @@ partitionLT_GT y (T a x b) = minView E = fail "UnbalancedSet.minView: empty collection" minView (T E x b) = return (x, b) minView (T a x b) = return (y, T a' x b) - where Just (y,a') = minView a + where (y,a') = fromJust (minView a) minElem E = error "UnbalancedSet.minElem: empty collection" minElem (T E x _) = x @@ -289,7 +290,7 @@ minElem (T a _ _) = minElem a maxView E = fail "UnbalancedSet.maxView: empty collection" maxView (T a x E) = return (x, a) maxView (T a x b) = return (y, T a x b') - where Just (y, b') = maxView b + where (y, b') = fromJust (maxView b) maxElem E = error "UnbalancedSet.maxElem: empty collection" maxElem (T _ x E) = x @@ -427,9 +428,9 @@ instance (Ord a, Arbitrary a) => Arbitrary (Set a) where return (Prelude.foldr insert empty xs) instance (Ord a, CoArbitrary a) => CoArbitrary (Set a) where - coarbitrary E = variant 0 + coarbitrary E = variant (0 :: Int) coarbitrary (T a x b) = - variant 1 . coarbitrary a . coarbitrary x . coarbitrary b + variant (1 :: Int) . coarbitrary a . coarbitrary x . coarbitrary b instance (Ord a) => Semigroup (Set a) where (<>) = union diff --git a/edison-core/src/Data/Edison/Concrete/FingerTree.hs b/edison-core/src/Data/Edison/Concrete/FingerTree.hs index 6c72eca..dfe2401 100644 --- a/edison-core/src/Data/Edison/Concrete/FingerTree.hs +++ b/edison-core/src/Data/Edison/Concrete/FingerTree.hs @@ -750,11 +750,11 @@ instance (Arbitrary a) => Arbitrary (Digit a) where instance (CoArbitrary a) => CoArbitrary (Digit a) where coarbitrary p = case p of - One x -> variant 0 . coarbitrary x - Two x y -> variant 1 . coarbitrary x . coarbitrary y - Three x y z -> variant 2 . coarbitrary x . coarbitrary y + One x -> variant (0 :: Int) . coarbitrary x + Two x y -> variant (1 :: Int) . coarbitrary x . coarbitrary y + Three x y z -> variant (2 :: Int) . coarbitrary x . coarbitrary y . coarbitrary z - Four x y z w -> variant 3 . coarbitrary x . coarbitrary y + Four x y z w -> variant (3 :: Int) . coarbitrary x . coarbitrary y . coarbitrary z . coarbitrary w @@ -766,8 +766,8 @@ instance (Measured v a, Arbitrary a) => Arbitrary (Node v a) where instance (Measured v a, CoArbitrary a) => CoArbitrary (Node v a) where coarbitrary p = case p of - Node2 _ x y -> variant 0 . coarbitrary x . coarbitrary y - Node3 _ x y z -> variant 1 . coarbitrary x . coarbitrary y . coarbitrary z + Node2 _ x y -> variant (0 :: Int) . coarbitrary x . coarbitrary y + Node3 _ x y z -> variant (1 :: Int) . coarbitrary x . coarbitrary y . coarbitrary z instance (Measured v a, Arbitrary a) => Arbitrary (FingerTree v a) where @@ -783,6 +783,6 @@ instance (Measured v a, Arbitrary a) => Arbitrary (FingerTree v a) where instance (Measured v a, CoArbitrary a) => CoArbitrary (FingerTree v a) where coarbitrary p = case p of - Empty -> variant 0 - Single x -> variant 1 . coarbitrary x - Deep _ sf m pf -> variant 2 . coarbitrary sf . coarbitrary m . coarbitrary pf + Empty -> variant (0 :: Int) + Single x -> variant (1 :: Int) . coarbitrary x + Deep _ sf m pf -> variant (2 :: Int) . coarbitrary sf . coarbitrary m . coarbitrary pf diff --git a/edison-core/src/Data/Edison/Seq/BinaryRandList.hs b/edison-core/src/Data/Edison/Seq/BinaryRandList.hs index 0a89712..dc44c74 100644 --- a/edison-core/src/Data/Edison/Seq/BinaryRandList.hs +++ b/edison-core/src/Data/Edison/Seq/BinaryRandList.hs @@ -456,9 +456,9 @@ instance Arbitrary a => Arbitrary (Seq a) where return (fromList xs) instance CoArbitrary a => CoArbitrary (Seq a) where - coarbitrary E = variant 0 - coarbitrary (Even ps) = variant 1 . coarbitrary ps - coarbitrary (Odd x ps) = variant 2 . coarbitrary x . coarbitrary ps + coarbitrary E = variant (0 :: Int) + coarbitrary (Even ps) = variant (1 :: Int) . coarbitrary ps + coarbitrary (Odd x ps) = variant (2 :: Int) . coarbitrary x . coarbitrary ps instance Semigroup (Seq a) where diff --git a/edison-core/src/Data/Edison/Seq/BraunSeq.hs b/edison-core/src/Data/Edison/Seq/BraunSeq.hs index e3524c1..67eb914 100644 --- a/edison-core/src/Data/Edison/Seq/BraunSeq.hs +++ b/edison-core/src/Data/Edison/Seq/BraunSeq.hs @@ -326,9 +326,6 @@ toList t = tol [t] root (B x _ _) = x root _ = error "BraunSeq.toList: bug!" - (B _ a _) = a --- (left _) = error "BraunSeq.toList: bug!" - map _ E = E map f (B x a b) = B (f x) (map f a) (map f b) diff --git a/edison-core/src/Data/Edison/Seq/Defaults.hs b/edison-core/src/Data/Edison/Seq/Defaults.hs index ab05796..45b8048 100644 --- a/edison-core/src/Data/Edison/Seq/Defaults.hs +++ b/edison-core/src/Data/Edison/Seq/Defaults.hs @@ -475,7 +475,9 @@ readsPrecUsingFromList _ xs = -- play games with the typechecker so we don't have to use -- extensions for scoped type variables - ~[(x,_)] = result + x = case result of + [(x',_)] -> x' + _ -> undefined in result diff --git a/edison-core/src/Data/Edison/Seq/JoinList.hs b/edison-core/src/Data/Edison/Seq/JoinList.hs index 8168e9e..455b85f 100644 --- a/edison-core/src/Data/Edison/Seq/JoinList.hs +++ b/edison-core/src/Data/Edison/Seq/JoinList.hs @@ -432,9 +432,9 @@ instance Arbitrary a => Arbitrary (Seq a) where (arbTree (n `div` 2)))] instance CoArbitrary a => CoArbitrary (Seq a) where - coarbitrary E = variant 0 - coarbitrary (L x) = variant 1 . coarbitrary x - coarbitrary (A xs ys) = variant 2 . coarbitrary xs . coarbitrary ys + coarbitrary E = variant (0 :: Int) + coarbitrary (L x) = variant (1 :: Int) . coarbitrary x + coarbitrary (A xs ys) = variant (2 :: Int) . coarbitrary xs . coarbitrary ys instance Semigroup (Seq a) where (<>) = append