leancheck-instances 0.0.5 → 0.0.6
raw patch · 17 files changed
+297/−90 lines, 17 filesdep +these
Dependencies added: these
Files
- .github/workflows/build.yml +99/−52
- Makefile +12/−1
- README.md +14/−14
- bench/tiers.hs +3/−0
- changelog.md +8/−1
- leancheck-instances.cabal +7/−10
- mk/ghcdeps +1/−1
- mk/haddock-i +1/−1
- mk/haskell.mk +11/−3
- mk/install-on +1/−1
- src/Test/LeanCheck/Instances.hs +1/−0
- src/Test/LeanCheck/Instances/Natural.hs +1/−1
- stack.yaml +2/−2
- test/diff/tiers-TheseIntInt.out +125/−0
- test/main.hs +4/−0
- test/sdist +6/−2
- test/text.hs +1/−1
.github/workflows/build.yml view
@@ -1,46 +1,62 @@ # Builds and tests this Haskell project on "GitHub Actions" #-# 2021 Rudy Matela+# 2021-2024 Rudy Matela #-# some docs: https://github.com/haskell/actions/tree/main/setup+# some docs: https://github.com/haskell-actions/setup+#+# The official haskell docker image: https://hub.docker.com/_/haskell name: build on: [push] jobs: build-and-test: runs-on: ubuntu-latest steps:+ - run: git --version+ - run: make --version+ - run: ghc --version+ - run: cabal --version - - name: Cache ~/.cabal/packages- uses: actions/cache@v2+ - name: Check out repository+ uses: actions/checkout@v3++ # check out needs to happen before cache so that hashing works+ - name: Cache hash+ run: echo Cache hash = ${{ hashFiles('*.cabal') }}++ - name: Cache cabal (source) packages+ uses: actions/cache@v3 with:- path: ~/.cabal/packages- key: v1-${{ runner.os }}-cabal-packages-${{ hashFiles('hello.cabal') }}+ path: |+ ~/.cabal/packages+ ~/.cache/cabal+ key: v1-${{ runner.os }}-cabal-packages-${{ hashFiles('*.cabal') }} restore-keys: v1-${{ runner.os }}-cabal-packages- - - name: Cache ~/.cabal and ~/.ghc- uses: actions/cache@v2+ - name: Cache installed cabal packages+ uses: actions/cache@v3 with: path: | ~/.cabal !~/.cabal/packages+ ~/.config/cabal+ ~/.local/state/cabal ~/.ghc- key: v1-${{ runner.os }}-cabal-ghc-latest-${{ hashFiles('hello.cabal') }}- restore-keys: v1-${{ runner.os }}-cabal-ghc-latest--- - run: du -hd3 ~/.cabal ~/.ghc || true+ key: v1-${{ runner.os }}-cabal-ghc-latest-${{ hashFiles('*.cabal') }}+ restore-keys: v1-${{ runner.os }}-cabal-ghc-latest-${{ hashFiles('*.cabal') }}+ # restore with exact match has some versions of cabal have trouble updating - run: haddock --version || sudo apt-get install ghc-haddock- - run: ghc --version- - run: cabal --version- - run: haddock --version- - run: ghc-pkg list+ # blank line+ # blank line for alignment with matrix scripts - - name: Check out repository- uses: actions/checkout@v2+ - run: du -hd3 ~/.ghc ~/.cabal ~/.config/cabal ~/.cache/cabal ~/.local/state/cabal || true - - run: cabal update+ - run: ghc-pkg list - run: make install-dependencies+ - run: ghc-pkg list + - run: du -hd3 ~/.ghc ~/.cabal ~/.config/cabal ~/.cache/cabal ~/.local/state/cabal || true+ - run: make - run: make test - run: make haddock@@ -50,57 +66,67 @@ test-with-ghc: strategy:+ max-parallel: 6 matrix:+ # starting with 9.10, docker/_/haskell requires -bullseye as suffix ghc:+ - '9.10-bullseye'+ - '9.8'+ - '9.6' - '9.4' - '9.2' - '9.0'- - '8.10' - '8.8'- - '8.6'- - '8.4'- - '8.2'- - '8.0'- - '7.10'- - '7.8' runs-on: ubuntu-latest needs: build-and-test container: haskell:${{ matrix.ghc }} steps:- - name: Cache ~/.cabal/packages- uses: actions/cache@v2+ - run: git --version || true # git is missing in some images+ - run: make --version || true # make is missing in some images+ - run: ghc --version+ - run: cabal --version++ - name: Check out repository+ uses: actions/checkout@v3++ # check out needs to happen before cache so that hashing works+ - name: Cache hash+ run: echo Cache hash = ${{ hashFiles('*.cabal') }}++ - name: Cache cabal (source) packages+ uses: actions/cache@v3 with:- path: ~/.cabal/packages- key: v1-${{ runner.os }}-cabal-packages-${{ hashFiles('hello.cabal') }}+ path: |+ ~/.cabal/packages+ ~/.cache/cabal+ key: v1-${{ runner.os }}-cabal-packages-${{ hashFiles('*.cabal') }} restore-keys: v1-${{ runner.os }}-cabal-packages- - - name: Cache ~/.cabal and ~/.ghc- uses: actions/cache@v2+ - name: Cache installed cabal packages+ uses: actions/cache@v3 with: path: | ~/.cabal !~/.cabal/packages+ ~/.config/cabal+ ~/.local/state/cabal ~/.ghc- key: v1-${{ runner.os }}-cabal-ghc-${{ matrix.ghc }}-${{ hashFiles('hello.cabal') }}- restore-keys: v1-${{ runner.os }}-cabal-ghc-${{ matrix.ghc }}--- - run: du -hd3 ~/.cabal ~/.ghc || true+ key: v1-${{ runner.os }}-cabal-ghc-${{ matrix.ghc }}-${{ hashFiles('*.cabal') }}+ restore-keys: v1-${{ runner.os }}-cabal-ghc-${{ matrix.ghc }}-${{ hashFiles('*.cabal') }}+ # restore with exact match has some versions of cabal have trouble updating - run: make --version || rm /etc/apt/sources.list.d/*.list # faster update - run: make --version || apt-get update - run: make --version || apt-get install make - - run: ghc --version- - run: cabal --version- - run: haddock --version- - run: ghc-pkg list-- - name: Check out repository- uses: actions/checkout@v2+ - run: du -hd3 ~/.ghc ~/.cabal ~/.config/cabal ~/.cache/cabal ~/.local/state/cabal || true - - run: cabal update+ - run: ghc-pkg list - run: make install-dependencies+ - run: ghc-pkg list + - run: du -hd3 ~/.ghc ~/.cabal ~/.config/cabal ~/.cache/cabal ~/.local/state/cabal || true+ - run: make - run: make test - run: make haddock@@ -111,20 +137,41 @@ runs-on: ubuntu-latest needs: build-and-test steps:- - name: Setup Haskell's GHC and Cabal as required by current Stackage LTS- uses: haskell/actions/setup@v1- with: # lts-19.19- ghc-version: '9.0.2'- cabal-version: '3.4'+ - name: Check out repository+ uses: actions/checkout@v3 - - uses: actions/cache@v2+ # check out needs to happen before cache so that hashing works+ - name: Cache hash+ run: echo Cache hash = ${{ hashFiles('stack.yaml') }}++ - name: Cache stack folder+ uses: actions/cache@v3 with: path: ~/.stack key: v1-${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }} restore-keys: v1-${{ runner.os }}-stack- + - name: Cache ghcup folder+ uses: actions/cache@v3+ with:+ path: |+ ~/.ghcup+ /usr/local/.ghcup/bin+ /usr/local/.ghcup/db+ /usr/local/.ghcup/ghc/9.4.8+ key: v1-${{ runner.os }}-ghcup-${{ hashFiles('stack.yaml') }}+ restore-keys: v1-${{ runner.os }}-ghcup-++ - name: Setup Haskell's GHC and Cabal as required by current Stackage LTS+ uses: haskell-actions/setup@v2+ with: # lts-21.25+ ghc-version: '9.4.8'+ cabal-version: '3.8'++ - run: du -hd2 ~/.stack ~/.ghcup /usr/local/.ghcup || true+ - run: stack --version - - name: Check out repository- uses: actions/checkout@v2 - run: make test-via-stack++ - run: du -hd2 ~/.stack ~/.ghcup /usr/local/.ghcup || true
Makefile view
@@ -3,6 +3,7 @@ # Copyright: (c) 2015-2022 Rudy Matela # License: 3-Clause BSD (see the file LICENSE) # Maintainer: Rudy Matela <rudy@matela.com.br>+GHC=ghc-9.10 TESTS = test/main \ test/text EGS = \@@ -14,7 +15,9 @@ GHCFLAGS = -v0 -O2 $(shell grep -q "Arch Linux" /etc/lsb-release && echo -dynamic) HADDOCKFLAGS = \ $(shell grep -q "Arch Linux" /etc/lsb-release && echo --optghc=-dynamic)-INSTALL_DEPS = leancheck bytestring nats text --avoid-reinstalls+BASE_DEPS = containers array time+INSTALL_DEPS = leancheck bytestring nats text \+ $(shell cabal --version | grep -q "version [0-2]\." || echo $(BASE_DEPS)) all: mk/toplibs @@ -58,6 +61,12 @@ test-via-stack: stack test leancheck-instances:test:main --ghc-options="$(GHCFLAGS) -O0" --system-ghc --no-install-ghc --no-terminal +test-with-ghc-9.12:+ make test GHC=ghc-9.12 GHCIMPORTDIRS=src:test:../leancheck/src++test-with-ghc-9.10:+ make test GHC=ghc-9.10 GHCIMPORTDIRS=src:test:../leancheck/src+ legacy-test: # needs ghc-8.2 .. ghc-7.8 installed as such make clean && make test GHC=ghc-8.2 GHCFLAGS="-Werror -dynamic" make clean && make test GHC=ghc-8.0 GHCFLAGS="-Werror -dynamic"@@ -106,6 +115,7 @@ ./bench/tiers "Day" 9 | diff -rud test/diff/tiers-Day.out - ./bench/tiers "DiffTime" | diff -rud test/diff/tiers-DiffTime.out - ./bench/tiers "Array Int Int" | diff -rud test/diff/tiers-ArrayIntInt.out -+ ./bench/tiers "These Int Int" | diff -rud test/diff/tiers-TheseIntInt.out - update-diff-test-tiers: bench/tiers ./bench/tiers "Natural" > test/diff/tiers-Natural.out@@ -123,3 +133,4 @@ ./bench/tiers "Day" 9 > test/diff/tiers-Day.out ./bench/tiers "DiffTime" > test/diff/tiers-DiffTime.out ./bench/tiers "Array Int Int" > test/diff/tiers-ArrayIntInt.out+ ./bench/tiers "These Int Int" > test/diff/tiers-TheseIntInt.out
README.md view
@@ -83,19 +83,19 @@ If needed, create a module that will contain your instance following the same structure in [quickcheck-instances]: - $ cat > src/Test/LeanCheck/Instances/Something.hs- -- |- -- Module : Test.LeanCheck.Instances.Containers- -- Copyright : (c) 2019 Authors of leancheck-instances- -- License : 3-Clause BSD (see the file LICENSE)- -- Maintainer : Rudy Matela <rudy@matela.com.br>- --- -- 'Listable' something.- module Test.LeanCheck.Instances.Something () where+ $ cat > src/Test/LeanCheck/Instances/Something.hs+ -- |+ -- Module : Test.LeanCheck.Instances.Containers+ -- Copyright : (c) 2019 Authors of leancheck-instances+ -- License : 3-Clause BSD (see the file LICENSE)+ -- Maintainer : Rudy Matela <rudy@matela.com.br>+ --+ -- 'Listable' something.+ module Test.LeanCheck.Instances.Something () where - import Test.LeanCheck- import Something- ^D+ import Test.LeanCheck+ import Something+ ^D Remember to: @@ -113,8 +113,8 @@ Open the relevant module with your favourite text editor and add your instance: - instance ... => Listable Something where- ...+ instance ... => Listable Something where+ ... Check the existing modules and the [`Listable`] typeclass documentation for how to create one.
bench/tiers.hs view
@@ -20,6 +20,7 @@ import Data.Text (Text) import Data.Time import Numeric.Natural+import Data.These dropEmptyTiersTail :: [[a]] -> [[a]] dropEmptyTiersTail ([]:[]:[]: []:[]:[]: _) = []@@ -115,5 +116,7 @@ "Day" -> put t n (u :: Day ) "DiffTime" -> put t n (u :: DiffTime ) "UTCTime" -> put t n (u :: UTCTime )+ -- other+ "These Int Int" -> put t n (u :: These Int Int ) -- unhandled _ -> putStrLn $ "unknown/unhandled type `" ++ t ++ "'"
changelog.md view
@@ -1,6 +1,13 @@ Changelog for leancheck-instances ================================= ++v0.0.6+------++* fix tests on GHC 9.10++ v0.0.5 ------ @@ -11,7 +18,7 @@ v0.0.4 ------ -* minor improvement on Listable UTCTime+* minor improvement on `Listable UTCTime` * improve tests
leancheck-instances.cabal view
@@ -1,6 +1,6 @@ -- Cabal file for leancheck-instances name: leancheck-instances-version: 0.0.5+version: 0.0.6 synopsis: Common LeanCheck instances description: Listable instances for types provided by the Haskell Platform.@@ -36,17 +36,13 @@ , test/diff/*.out , test/diff/eg/*.out , test/sdist-tested-with: GHC==9.4+tested-with: GHC==9.10+ , GHC==9.8+ , GHC==9.6+ , GHC==9.4 , GHC==9.2 , GHC==9.0- , GHC==8.10 , GHC==8.8- , GHC==8.6- , GHC==8.4- , GHC==8.2- , GHC==8.0- , GHC==7.10- , GHC==7.8 source-repository head@@ -56,7 +52,7 @@ source-repository this type: git location: https://github.com/rudymatela/leancheck-instances- tag: v0.0.5+ tag: v0.0.6 library exposed-modules: Test.LeanCheck.Instances@@ -77,6 +73,7 @@ , text , time , array+ , these default-language: Haskell2010 test-suite main
mk/ghcdeps view
@@ -2,7 +2,7 @@ # # ghcdeps: generate Haskell make dependencies for compiling with GHC. #-# Copyright (c) 2015-2021 Rudy Matela.+# Copyright (c) 2015-2024 Rudy Matela. # Distributed under the 3-Clause BSD licence. # # From a list of files provided on standard input,
mk/haddock-i view
@@ -2,7 +2,7 @@ # # haddock-i: list haddock's -i parameters. #-# Copyright (c) 2015-2021 Rudy Matela.+# Copyright (c) 2015-2024 Rudy Matela. # Distributed under the 3-Clause BSD licence. # # $ haddock-i <package1> <package2> ... <packageN>
mk/haskell.mk view
@@ -1,6 +1,6 @@ # Implicit rules for compiling Haskell code. #-# Copyright (c) 2015-2021 Rudy Matela.+# Copyright (c) 2015-2024 Rudy Matela. # Distributed under the 3-Clause BSD licence. # # You can optionally configure the "Configuration variables" below in your main@@ -21,7 +21,7 @@ GHC ?= ghc GHCCMD = $(GHC) -i$(GHCIMPORTDIRS) $(GHCFLAGS) HADDOCK ?= haddock-CABAL_INSTALL = $(shell cabal --version | grep -q "version [0-2]\." && echo 'cabal install' || echo 'cabal v1-install')+CABAL_INSTALL = $(shell cabal --version | grep -q "version [0-2]\." && echo 'cabal install' || echo 'cabal install --lib') # Hugs Parameters HUGSIMPORTDIRS ?= "/usr/lib/hugs/packages/*"@@ -90,7 +90,15 @@ find $(ALL_HSS) | ./mk/ghcdeps -i$(GHCIMPORTDIRS) $(GHCFLAGS) > $(DEPMK) install-dependencies:- $(CABAL_INSTALL) $(INSTALL_DEPS)+ if [ -n "$(INSTALL_DEPS)" ]; then \+ cd ~ && \+ cabal update && \+ $(CABAL_INSTALL) $(INSTALL_DEPS) || true; \+ fi+ # above, "|| true" is needed for cabal >= 3.10.2+ # Before, cabal would successfully skip installation+ # of already existing packages+ # cd ~ is needed so cabal installs only dependencies # haddock rules haddock: doc/index.html
mk/install-on view
@@ -2,7 +2,7 @@ # # mk/install-on: install or updates the mk folder on a Haskell project #-# Copyright (c) 2019-2021 Rudy Matela.+# Copyright (c) 2019-2024 Rudy Matela. # Distributed under the 3-Clause BSD licence. # # usage: ./mk/install-on path/to/project
src/Test/LeanCheck/Instances.hs view
@@ -40,3 +40,4 @@ import Test.LeanCheck.Instances.Containers () import Test.LeanCheck.Instances.Time () import Test.LeanCheck.Instances.Void ()+import Test.LeanCheck.Instances.These ()
src/Test/LeanCheck/Instances/Natural.hs view
@@ -11,4 +11,4 @@ import Test.LeanCheck instance Listable Natural where- list = [0..]+ list = [0..]
stack.yaml view
@@ -1,7 +1,7 @@-resolver: lts-19.19 # or ghc-9.0.2+resolver: lts-21.25 # or ghc-9.4.8 packages: - . extra-deps:-- leancheck-1.0.0+- leancheck-1.0.2
+ test/diff/tiers-TheseIntInt.out view
@@ -0,0 +1,125 @@+map length (tiers :: [[ These Int Int ]]) = [3,4,5,6,7,8,9,10,11,12,13,14,...]++length (list :: [ These Int Int ]) = Infinity++allUnique (list :: [ These Int Int ]) = True++ratioRepetitions (list :: [ These Int Int ]) = 0 % 1++tiers :: [These Int Int] =+ [ [ This 0+ , That 0+ , These 0 0+ ]+ , [ This 1+ , That 1+ , These 0 1+ , These 1 0+ ]+ , [ This (-1)+ , That (-1)+ , These 0 (-1)+ , These 1 1+ , These (-1) 0+ ]+ , [ This 2+ , That 2+ , These 0 2+ , These 1 (-1)+ , These (-1) 1+ , These 2 0+ ]+ , [ This (-2)+ , That (-2)+ , These 0 (-2)+ , These 1 2+ , These (-1) (-1)+ , These 2 1+ , These (-2) 0+ ]+ , [ This 3+ , That 3+ , These 0 3+ , These 1 (-2)+ , These (-1) 2+ , These 2 (-1)+ , These (-2) 1+ , These 3 0+ ]+ , [ This (-3)+ , That (-3)+ , These 0 (-3)+ , These 1 3+ , These (-1) (-2)+ , These 2 2+ , These (-2) (-1)+ , These 3 1+ , These (-3) 0+ ]+ , [ This 4+ , That 4+ , These 0 4+ , These 1 (-3)+ , These (-1) 3+ , These 2 (-2)+ , These (-2) 2+ , These 3 (-1)+ , These (-3) 1+ , These 4 0+ ]+ , [ This (-4)+ , That (-4)+ , These 0 (-4)+ , These 1 4+ , These (-1) (-3)+ , These 2 3+ , These (-2) (-2)+ , These 3 2+ , These (-3) (-1)+ , These 4 1+ , These (-4) 0+ ]+ , [ This 5+ , That 5+ , These 0 5+ , These 1 (-4)+ , These (-1) 4+ , These 2 (-3)+ , These (-2) 3+ , These 3 (-2)+ , These (-3) 2+ , These 4 (-1)+ , These (-4) 1+ , These 5 0+ ]+ , [ This (-5)+ , That (-5)+ , These 0 (-5)+ , These 1 5+ , These (-1) (-4)+ , These 2 4+ , These (-2) (-3)+ , These 3 3+ , These (-3) (-2)+ , These 4 2+ , These (-4) (-1)+ , These 5 1+ , These (-5) 0+ ]+ , [ This 6+ , That 6+ , These 0 6+ , These 1 (-5)+ , These (-1) 5+ , These 2 (-4)+ , These (-2) 4+ , These 3 (-3)+ , These (-3) 3+ , These 4 (-2)+ , These (-4) 2+ , These 5 (-1)+ , These (-5) 1+ , These 6 0+ ]+ , ...+ ]
test/main.hs view
@@ -12,6 +12,7 @@ import qualified Data.Map as Map import qualified Data.Sequence as Seq import Numeric.Natural+import Data.These import Test.LeanCheck import Test.LeanCheck.Instances@@ -47,4 +48,7 @@ , fails n $ \m1 m2 -> m1 `Map.union` m2 == m2 `Map.union` (m1 :: Map Int Int) , holds n $ \m1 -> m1 `Map.union` m1 == (m1 :: Map Int Int)++ , fails n $ \t -> let p = uncurry (*) (fromThese 2 3 t) :: Int+ in p `mod` 2 == 0 || p `mod` 3 == 0 ]
test/sdist view
@@ -2,7 +2,7 @@ # # test/sdist: tests the package generated by "cabal sdist". #-# Copyright (c) 2015-2021 Rudy Matela.+# Copyright (c) 2015-2024 Rudy Matela. # Distributed under the 3-Clause BSD licence. set -xe@@ -29,7 +29,11 @@ tar -tf $pkg | sort --ignore-case --unique > $tmp/ls-cabal-iu diff -rud $tmp/ls-cabal-i $tmp/ls-cabal-iu -if [ -d .git ]+# Check if we have a clone of the repo and git is available+# The check that we can run git ls-files is needed to avoid:+# fatal: detected dubious ownership in repository at '/__w/.../hello-haskell'+# on CI.+if [ -d .git ] && git --version && git ls-files >/dev/null then # Test if files included by cabal are the same as files tracked in git. git ls-files | sort > $tmp/ls-git
test/text.hs view
@@ -12,7 +12,7 @@ main = case elemIndices False (tests 1000) of [] -> putStrLn "Tests passed!"- is -> putStrLn ("Failed tests:" ++ show is) >> exitFailure+ is -> putStrLn ("Failed tests:" ++ Prelude.show is) >> exitFailure tests :: Int -> [Bool] tests n =