leancheck 0.9.4 → 0.9.6
raw patch · 12 files changed
+394/−150 lines, 12 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Test.LeanCheck.Utils.Types: data A
+ Test.LeanCheck.Utils.Types: data B
+ Test.LeanCheck.Utils.Types: data C
+ Test.LeanCheck.Utils.Types: data D
+ Test.LeanCheck.Utils.Types: data E
+ Test.LeanCheck.Utils.Types: data F
+ Test.LeanCheck.Utils.Types: instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.A
+ Test.LeanCheck.Utils.Types: instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.B
+ Test.LeanCheck.Utils.Types: instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.C
+ Test.LeanCheck.Utils.Types: instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.D
+ Test.LeanCheck.Utils.Types: instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.E
+ Test.LeanCheck.Utils.Types: instance GHC.Classes.Eq Test.LeanCheck.Utils.Types.F
+ Test.LeanCheck.Utils.Types: instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.A
+ Test.LeanCheck.Utils.Types: instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.B
+ Test.LeanCheck.Utils.Types: instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.C
+ Test.LeanCheck.Utils.Types: instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.D
+ Test.LeanCheck.Utils.Types: instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.E
+ Test.LeanCheck.Utils.Types: instance GHC.Classes.Ord Test.LeanCheck.Utils.Types.F
+ Test.LeanCheck.Utils.Types: instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.A
+ Test.LeanCheck.Utils.Types: instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.B
+ Test.LeanCheck.Utils.Types: instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.C
+ Test.LeanCheck.Utils.Types: instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.D
+ Test.LeanCheck.Utils.Types: instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.E
+ Test.LeanCheck.Utils.Types: instance GHC.Enum.Bounded Test.LeanCheck.Utils.Types.F
+ Test.LeanCheck.Utils.Types: instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.A
+ Test.LeanCheck.Utils.Types: instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.B
+ Test.LeanCheck.Utils.Types: instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.C
+ Test.LeanCheck.Utils.Types: instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.D
+ Test.LeanCheck.Utils.Types: instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.E
+ Test.LeanCheck.Utils.Types: instance GHC.Enum.Enum Test.LeanCheck.Utils.Types.F
+ Test.LeanCheck.Utils.Types: instance GHC.Ix.Ix Test.LeanCheck.Utils.Types.A
+ Test.LeanCheck.Utils.Types: instance GHC.Ix.Ix Test.LeanCheck.Utils.Types.B
+ Test.LeanCheck.Utils.Types: instance GHC.Ix.Ix Test.LeanCheck.Utils.Types.C
+ Test.LeanCheck.Utils.Types: instance GHC.Ix.Ix Test.LeanCheck.Utils.Types.D
+ Test.LeanCheck.Utils.Types: instance GHC.Ix.Ix Test.LeanCheck.Utils.Types.E
+ Test.LeanCheck.Utils.Types: instance GHC.Ix.Ix Test.LeanCheck.Utils.Types.F
+ Test.LeanCheck.Utils.Types: instance GHC.Num.Num Test.LeanCheck.Utils.Types.A
+ Test.LeanCheck.Utils.Types: instance GHC.Num.Num Test.LeanCheck.Utils.Types.B
+ Test.LeanCheck.Utils.Types: instance GHC.Num.Num Test.LeanCheck.Utils.Types.C
+ Test.LeanCheck.Utils.Types: instance GHC.Num.Num Test.LeanCheck.Utils.Types.D
+ Test.LeanCheck.Utils.Types: instance GHC.Num.Num Test.LeanCheck.Utils.Types.E
+ Test.LeanCheck.Utils.Types: instance GHC.Num.Num Test.LeanCheck.Utils.Types.F
+ Test.LeanCheck.Utils.Types: instance GHC.Read.Read Test.LeanCheck.Utils.Types.A
+ Test.LeanCheck.Utils.Types: instance GHC.Read.Read Test.LeanCheck.Utils.Types.B
+ Test.LeanCheck.Utils.Types: instance GHC.Read.Read Test.LeanCheck.Utils.Types.C
+ Test.LeanCheck.Utils.Types: instance GHC.Read.Read Test.LeanCheck.Utils.Types.D
+ Test.LeanCheck.Utils.Types: instance GHC.Read.Read Test.LeanCheck.Utils.Types.E
+ Test.LeanCheck.Utils.Types: instance GHC.Read.Read Test.LeanCheck.Utils.Types.F
+ Test.LeanCheck.Utils.Types: instance GHC.Real.Integral Test.LeanCheck.Utils.Types.A
+ Test.LeanCheck.Utils.Types: instance GHC.Real.Integral Test.LeanCheck.Utils.Types.B
+ Test.LeanCheck.Utils.Types: instance GHC.Real.Integral Test.LeanCheck.Utils.Types.C
+ Test.LeanCheck.Utils.Types: instance GHC.Real.Integral Test.LeanCheck.Utils.Types.D
+ Test.LeanCheck.Utils.Types: instance GHC.Real.Integral Test.LeanCheck.Utils.Types.E
+ Test.LeanCheck.Utils.Types: instance GHC.Real.Integral Test.LeanCheck.Utils.Types.F
+ Test.LeanCheck.Utils.Types: instance GHC.Real.Real Test.LeanCheck.Utils.Types.A
+ Test.LeanCheck.Utils.Types: instance GHC.Real.Real Test.LeanCheck.Utils.Types.B
+ Test.LeanCheck.Utils.Types: instance GHC.Real.Real Test.LeanCheck.Utils.Types.C
+ Test.LeanCheck.Utils.Types: instance GHC.Real.Real Test.LeanCheck.Utils.Types.D
+ Test.LeanCheck.Utils.Types: instance GHC.Real.Real Test.LeanCheck.Utils.Types.E
+ Test.LeanCheck.Utils.Types: instance GHC.Real.Real Test.LeanCheck.Utils.Types.F
+ Test.LeanCheck.Utils.Types: instance GHC.Show.Show Test.LeanCheck.Utils.Types.A
+ Test.LeanCheck.Utils.Types: instance GHC.Show.Show Test.LeanCheck.Utils.Types.B
+ Test.LeanCheck.Utils.Types: instance GHC.Show.Show Test.LeanCheck.Utils.Types.C
+ Test.LeanCheck.Utils.Types: instance GHC.Show.Show Test.LeanCheck.Utils.Types.D
+ Test.LeanCheck.Utils.Types: instance GHC.Show.Show Test.LeanCheck.Utils.Types.E
+ Test.LeanCheck.Utils.Types: instance GHC.Show.Show Test.LeanCheck.Utils.Types.F
+ Test.LeanCheck.Utils.Types: instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.A
+ Test.LeanCheck.Utils.Types: instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.B
+ Test.LeanCheck.Utils.Types: instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.C
+ Test.LeanCheck.Utils.Types: instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.D
+ Test.LeanCheck.Utils.Types: instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.E
+ Test.LeanCheck.Utils.Types: instance Test.LeanCheck.Core.Listable Test.LeanCheck.Utils.Types.F
Files
- .github/workflows/build.yml +131/−0
- .gitignore +2/−0
- .travis.yml +0/−125
- Makefile +4/−3
- README.md +23/−6
- changelog.md +9/−0
- leancheck.cabal +3/−3
- mk/haskell.mk +10/−11
- src/Test/LeanCheck/Function/Ord.hs +1/−1
- src/Test/LeanCheck/Utils/Types.hs +196/−0
- stack.yaml +1/−1
- test/types.hs +14/−0
+ .github/workflows/build.yml view
@@ -0,0 +1,131 @@+# Builds and tests this Haskell project on "GitHub Actions"+#+# 2021 Rudy Matela+#+# some docs: https://github.com/haskell/actions/tree/main/setup+name: build+on: [push]+jobs:+ build-and-test:+ runs-on: ubuntu-latest+ steps:++ - name: Cache ~/.cabal/packages+ uses: actions/cache@v2+ with:+ path: ~/.cabal/packages+ key: v1-${{ runner.os }}-cabal-packages-${{ hashFiles('hello.cabal') }}+ restore-keys: v1-${{ runner.os }}-cabal-packages-++ - name: Cache ~/.cabal and ~/.ghc+ uses: actions/cache@v2+ with:+ path: |+ ~/.cabal+ !~/.cabal/packages+ ~/.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++ - run: haddock --version || sudo apt-get install ghc-haddock+ - run: ghc --version+ - run: cabal --version++ - name: Check out repository+ uses: actions/checkout@v2++ - run: cabal update+ - run: make install-dependencies++ - run: make+ - run: make test+ - run: make haddock+ - run: make test-sdist+ - run: make test-via-cabal+++ test-with-ghc:+ strategy:+ matrix:+ ghc:+ - '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+ with:+ path: ~/.cabal/packages+ key: v1-${{ runner.os }}-cabal-packages-${{ hashFiles('hello.cabal') }}+ restore-keys: v1-${{ runner.os }}-cabal-packages-++ - name: Cache ~/.cabal and ~/.ghc+ uses: actions/cache@v2+ with:+ path: |+ ~/.cabal+ !~/.cabal/packages+ ~/.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++ - 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++ - name: Check out repository+ uses: actions/checkout@v2++ - run: cabal update+ - run: make install-dependencies++ - run: make+ - run: make test+ - run: make haddock+ - run: make test-sdist+ - run: make test-via-cabal++ test-with-stack:+ 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-17.9+ ghc-version: '8.10.4'+ cabal-version: '3.2'++ - uses: actions/cache@v2+ with:+ path: ~/.stack+ key: v1-${{ runner.os }}-stack-${{ hashFiles('stack.yaml') }}+ restore-keys: v1-${{ runner.os }}-stack-++ - name: Check out repository+ uses: actions/checkout@v2+ - run: make test-via-stack++ test-with-hugs:+ runs-on: ubuntu-latest+ needs: build-and-test+ steps:+ - run: sudo apt-get install hugs+ - name: Check out repository+ uses: actions/checkout@v2+ - run: make hugs-test
.gitignore view
@@ -1,5 +1,7 @@ .cabal-sandbox cabal.sandbox.config+cabal.project.local+cabal.project.local~ .stack-work idx/ dist/
− .travis.yml
@@ -1,125 +0,0 @@-# .travis.yml file for LeanCheck-#-# Copyright: (c) 2017-2021 Rudy Matela-# License: 3-Clause BSD (see the file LICENSE)-# Maintainer: Rudy Matela <rudy@matela.com.br>--language: c # not really--notifications:- email:- on_failure: change--sudo: false--cache:- directories:- - $HOME/.ghc- - $HOME/.cabal- - $HOME/.stack--before_install:-- export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH-- ghc --version-- cabal --version-- haddock --version-- du -hd3 ~/.cabal ~/.ghc || true-- du -hd4 ~/.stack || true-- rm -f ~/.cabal/config && cabal update-# Download and unpack the stack executable-# "Once Travis whitelists the stack.dev files," simply include stack in the-# addons section. -- https://docs.haskellstack.org/en/stable/travis_ci/-- mkdir -p ~/.local/bin-- export PATH=$HOME/.local/bin:$PATH-- travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'-- stack config set system-ghc --global true-- stack --version---script:-- make && make test-- make haddock-- make test-sdist-- cabal test --ghc-option=-O0-- stack --resolver $STACKVER --no-terminal --skip-ghc-check test --ghc-options=-O0--matrix:- allow_failures:- - env: GHCVER=head CABALVER=head STACKVER=nightly-2021-04-06- - env: GHCVER=9.0.1 CABALVER=head STACKVER=nightly-2021-04-06- include:- - ghc: 'head'- env: GHCVER=head CABALVER=head STACKVER=nightly-2021-04-06- addons: {apt: {packages: [ghc-head, cabal-install-head], sources: hvr-ghc}}- - ghc: '9.0'- env: GHCVER=9.0.1 CABALVER=head STACKVER=nightly-2021-04-06- addons: {apt: {packages: [ghc-9.0.1, cabal-install-head], sources: hvr-ghc}}- - ghc: '8.10'- env: GHCVER=8.10.4 CABALVER=3.2 STACKVER=lts-17.9- addons: {apt: {packages: [ghc-8.10.4, cabal-install-3.2], sources: hvr-ghc}}- - ghc: '8.8'- env: GHCVER=8.8.4 CABALVER=3.0 STACKVER=lts-16.31- addons: {apt: {packages: [ghc-8.8.4, cabal-install-3.0], sources: hvr-ghc}}- - ghc: '8.6'- env: GHCVER=8.6.5 CABALVER=2.4 STACKVER=lts-14.27- addons: {apt: {packages: [ghc-8.6.5, cabal-install-2.4], sources: hvr-ghc}}- - ghc: '8.4'- env: GHCVER=8.4.4 CABALVER=2.2 STACKVER=lts-12.26- addons: {apt: {packages: [ghc-8.4.4, cabal-install-2.2], sources: hvr-ghc}}- - ghc: '8.2'- env: GHCVER=8.2.2 CABALVER=2.0 STACKVER=lts-11.22- addons: {apt: {packages: [ghc-8.2.2, cabal-install-2.0], sources: hvr-ghc}}- - ghc: '8.0'- env: GHCVER=8.0.2 CABALVER=1.24 STACKVER=lts-9.21- addons: {apt: {packages: [ghc-8.0.2, cabal-install-1.24], sources: hvr-ghc}}- - ghc: '7.10'- env: GHCVER=7.10.3 CABALVER=1.22 STACKVER=lts-6.35- addons: {apt: {packages: [ghc-7.10.3, cabal-install-1.22], sources: hvr-ghc}}- # we only support stack with GHC >= 7.10- - ghc: '7.8'- env: GHCVER=7.8.4 CABALVER=1.18- addons: {apt: {packages: [ghc-7.8.4, cabal-install-1.18], sources: hvr-ghc}}- before_install:- - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH- - ghc --version- - cabal --version- - haddock --version- script:- - make && make test- - make haddock HADDOCKFLAGS=- - make test-sdist- - cabal test- - ghc: '7.6'- env: GHCVER=7.6.3 CABALVER=1.18- addons: {apt: {packages: [ghc-7.6.3, cabal-install-1.18], sources: hvr-ghc}}- before_install:- - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH- - ghc --version- - cabal --version- - haddock --version- script:- - make GHCFLAGS= && make test GHCFLAGS=- - make haddock HADDOCKFLAGS=- - make test-sdist- - cabal test- - ghc: '7.4'- env: GHCVER=7.4.2 CABALVER=1.18- addons: {apt: {packages: [ghc-7.4.2, cabal-install-1.18], sources: hvr-ghc}}- before_install:- - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH- - ghc --version- - cabal --version- - haddock --version- script:- - make GHCFLAGS= && make test GHCFLAGS=- - make haddock HADDOCKFLAGS=- - make test-sdist- - cabal test- # Hugs is not a GHC version. But this is how travis can handle it.- - ghc: 'hugs'- env: GHCVER=hugs- addons: {apt: {packages: [hugs]}}- before_install:- - echo ":version" | hugs- script:- - make hugs-test
Makefile view
@@ -31,7 +31,6 @@ GHCIMPORTDIRS = src:test GHCFLAGS = -O2 $(shell grep -q "Arch Linux" /etc/lsb-release && echo -dynamic) \ -W -fno-warn-unused-matches -Werror-HADDOCKFLAGS = --no-print-missing-docs HUGSIMPORTDIRS = .:./src:./test:./etc/hugs-backports:/usr/lib/hugs/packages/* HUGSFLAGS = -98 -h32M @@ -99,10 +98,12 @@ ./test/sdist test-via-cabal:- cabal test+ cabal configure --enable-tests --enable-benchmarks --ghc-options="$(GHCFLAGS) -O0"+ cabal build+ cabal test main test-via-stack:- stack test+ stack test leancheck:test:main --ghc-options="$(GHCFLAGS) -O0" --system-ghc --no-install-ghc --no-terminal legacy-test: # needs ghc-8.8 .. ghc-7.8 installed as such make clean && make test -j GHC=ghc-8.8
README.md view
@@ -30,17 +30,34 @@ Installing ---------- -To install the latest LeanCheck version from Hackage, just run:+To install the latest LeanCheck version from Hackage using Cabal v3.0 or later, just run: + $ cabal v1-update+ $ cabal v1-install leancheck++If you are using a cabal earlier than v3.0, just run:+ $ cabal update $ cabal install leancheck -Starting from Cabal v3.0, you need to pass `--lib` as an argument to cabal-install:+With Cabal v3.0 or later,+[using `v1-install` is preferred for the time being.](https://github.com/haskell/cabal/issues/7373)+If all fails, you can start over by resetting your user's cabal installation+with: - $ cabal install leancheck --lib+ rm -rf ~/.cabal/{bin,lib,logs,share,store} ~/.ghc/*/ +WARNING: the above command will erase all user-local packages. +LeanCheck has (official) packages available on+[Stackage](https://www.stackage.org/package/leancheck),+[OpenSUSE](https://packagehub.suse.com/packages/ghc-leancheck/),+[Gentoo](https://packages.gentoo.org/packages/dev-haskell/leancheck),+[Arch Linux](https://archlinux.org/packages/community/x86_64/haskell-leancheck/) and+[NixOS](https://hydra.nixos.org/job/nixpkgs/trunk/haskellPackages.leancheck.x86_64-linux).+++ Checking if properties are True ------------------------------- @@ -273,8 +290,8 @@ [leancheck-logo]: https://github.com/rudymatela/leancheck/raw/master/doc/leancheck.svg?sanitize=true -[build-status]: https://travis-ci.org/rudymatela/leancheck.svg?branch=master-[build-log]: https://travis-ci.org/rudymatela/leancheck+[build-log]: https://github.com/rudymatela/leancheck/actions/workflows/build.yml+[build-status]: https://github.com/rudymatela/leancheck/actions/workflows/build.yml/badge.svg [hackage-version]: https://img.shields.io/hackage/v/leancheck.svg [leancheck-on-hackage]: https://hackage.haskell.org/package/leancheck [stackage-lts-badge]: https://stackage.org/package/leancheck/badge/lts
changelog.md view
@@ -1,6 +1,15 @@ Changelog for LeanCheck ======================= +v0.9.6+------++* no code changes in what is exported by `Test.LeanCheck`+* `Test.LeanCheck.Utils.Types`: export the `A`, `B`, `C`, `D`, `E` and `F` types+* slightly improve README+* improve Makefile and tests+* replace Travis by GitHub Actions as the CI system+ v0.9.4 ------
leancheck.cabal view
@@ -11,7 +11,7 @@ -- this cabal file too complicated. -- Rudy name: leancheck-version: 0.9.4+version: 0.9.6 synopsis: Enumerative property-based testing description: LeanCheck is a simple enumerative property-based testing library.@@ -45,7 +45,7 @@ , doc/tutorial.md , doc/leancheck.svg extra-source-files: .gitignore- , .travis.yml+ , .github/workflows/build.yml , Makefile , bench/dets.hs , bench/memory-usage.hs@@ -89,7 +89,7 @@ source-repository this type: git location: https://github.com/rudymatela/leancheck- tag: v0.9.4+ tag: v0.9.6 library exposed-modules: Test.LeanCheck
mk/haskell.mk view
@@ -21,6 +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') # Hugs Parameters HUGSIMPORTDIRS ?= "/usr/lib/hugs/packages/*"@@ -46,19 +47,13 @@ LIB_DEPS ?= base ALL_DEPS ?= $(LIB_DEPS)+INSTALL_DEPS ?= PKGNAME = $(shell cat *.cabal | grep "^name:" | sed -e "s/name: *//")-HADDOCK_VERSION = $(shell $(HADDOCK) --version | grep version | sed -e 's/.*version //;s/,.*//')-HADDOCK_MAJOR = $(shell echo $(HADDOCK_VERSION) | sed -e 's/\..*//')-HADDOCK_MINOR = $(shell echo $(HADDOCK_VERSION) | sed -e 's/[0-9]*\.\([0-9]*\).[0-9]*/\1/')-HADDOCK_PKG_NAME = $(shell [ $(HADDOCK_MAJOR) -gt 2 ] \- || [ $(HADDOCK_MAJOR) -eq 2 -a $(HADDOCK_MINOR) -ge 20 ] \- && echo "--package-name=$(PKGNAME)")-HADDOCK_HLNK_SRC = $(shell [ $(HADDOCK_MAJOR) -gt 2 ] \- || [ $(HADDOCK_MAJOR) -eq 2 -a $(HADDOCK_MINOR) -ge 17 ] \- && echo "--hyperlinked-source") +HADDOCK_HAS = haddock --help | grep -q -- + # Implicit rules %.hi %.o: %.hs $(GHCCMD) $< && touch $@@@ -94,6 +89,9 @@ depend: find $(ALL_HSS) | ./mk/ghcdeps -i$(GHCIMPORTDIRS) $(GHCFLAGS) > $(DEPMK) +install-dependencies:+ $(CABAL_INSTALL) $(INSTALL_DEPS)+ # haddock rules haddock: doc/index.html @@ -110,8 +108,9 @@ ./mk/haddock-i $(LIB_DEPS) | xargs \ $(HADDOCK) --html -odoc $(LIB_HSS) \ --title=$(PKGNAME) \- $(HADDOCK_PKG_NAME) \- $(HADDOCK_HLNK_SRC) \+ $(shell $(HADDOCK_HAS) --package-name && echo "--package-name=$(PKGNAME)" ) \+ $(shell $(HADDOCK_HAS) --hyperlinked-source && echo "--hyperlinked-source" ) \+ $(shell $(HADDOCK_HAS) --no-print-missing-docs && echo --no-print-missing-docs ) \ $(HADDOCKFLAGS) clean-cabal:
src/Test/LeanCheck/Function/Ord.hs view
@@ -36,7 +36,7 @@ import Test.LeanCheck.Core import Test.LeanCheck.Function.List-import Test.LeanCheck.Function.Eq+import Test.LeanCheck.Function.Eq () -- | Two functions are compared based on the results -- of twelve different enumerated values for each argument.
src/Test/LeanCheck/Utils/Types.hs view
@@ -78,6 +78,9 @@ , Digits (..) , AlphaNums (..) , Letters (..)++ -- * Generic types+ , A, B, C, D, E, F ) where @@ -187,6 +190,85 @@ -- | Natural numbers modulo 7: 0, 1, 2, 3, 4, 5, 6 newtype Nat7 = Nat7 { unNat7 :: Int } deriving (Eq, Ord) +-- | Generic type 'A'.+--+-- Can be used to test polymorphic functions with a type variable+-- such as 'take' or 'sort':+--+-- > take :: Int -> [a] -> [a]+-- > sort :: Ord a => [a] -> [a]+--+-- by binding them to the following types:+--+-- > take :: Int -> [A] -> [A]+-- > sort :: [A] -> [A]+--+-- This type is homomorphic to 'Nat6', 'B', 'C', 'D', 'E' and 'F'.+--+-- It is instance to several typeclasses so that it can be used+-- to test functions with type contexts.+newtype A = A Int deriving (Eq, Ord)++-- | Generic type 'B'.+--+-- Can be used to test polymorphic functions with two type variables+-- such as 'map' or 'foldr':+--+-- > map :: (a -> b) -> [a] -> [b]+-- > foldr :: (a -> b -> b) -> b -> [a] -> b+--+-- by binding them to the following types:+--+-- > map :: (A -> B) -> [A] -> [B]+-- > foldr :: (A -> B -> B) -> B -> [A] -> B+--+-- This type is homomorphic to 'A', 'Nat6', 'C', 'D', 'E' and 'F'.+newtype B = B Int deriving (Eq, Ord)++-- | Generic type 'C'.+--+-- Can be used to test polymorphic functions with three type variables+-- such as 'uncurry' or 'zipWith':+--+-- > uncurry :: (a -> b -> c) -> (a, b) -> c+-- > zipWith :: (a -> b -> c) -> [a] -> [b] -> [c]+--+-- by binding them to the following types:+--+-- > uncurry :: (A -> B -> C) -> (A, B) -> C+-- > zipWith :: (A -> B -> C) -> [A] -> [B] -> [C]+--+-- This type is homomorphic to 'A', 'B', 'Nat6', 'D', 'E' and 'F'.+newtype C = C Int deriving (Eq, Ord)++-- | Generic type 'D'.+--+-- Can be used to test polymorphic functions with four type variables.+--+-- This type is homomorphic to 'A', 'B', 'C', 'Nat6', 'E' and 'F'.+newtype D = D Int deriving (Eq, Ord)++-- | Generic type 'E'.+--+-- Can be used to test polymorphic functions with five type variables.+--+-- This type is homomorphic to 'A', 'B', 'C', 'D', 'Nat6' and 'F'.+newtype E = E Int deriving (Eq, Ord)++-- | Generic type 'F'.+--+-- Can be used to test polymorphic functions with five type variables.+--+-- This type is homomorphic to 'A', 'B', 'C', 'D', 'E' and 'Nat6'.+newtype F = F Int deriving (Eq, Ord)++unA :: A -> Int; unA (A n) = n+unB :: B -> Int; unB (B n) = n+unC :: C -> Int; unC (C n) = n+unD :: D -> Int; unD (D n) = n+unE :: E -> Int; unE (E n) = n+unF :: F -> Int; unF (F n) = n+ int1 :: Int -> Int1; int1 = Int1 . narrowS 1 int2 :: Int -> Int2; int2 = Int2 . narrowS 2 int3 :: Int -> Int3; int3 = Int3 . narrowS 3@@ -204,6 +286,12 @@ nat7 :: Int -> Nat7; nat7 = Nat7 . (`mod` 7) nat :: Int -> Nat; nat = Nat . (\x -> if x < 0 then 0 else x) natural :: Integer -> Natural; natural = Natural . (\x -> if x < 0 then 0 else x)+mkA :: Int -> A; mkA = A . (`mod` 6)+mkB :: Int -> B; mkB = B . (`mod` 6)+mkC :: Int -> C; mkC = C . (`mod` 6)+mkD :: Int -> D; mkD = D . (`mod` 6)+mkE :: Int -> E; mkE = E . (`mod` 6)+mkF :: Int -> F; mkF = F . (`mod` 6) oInt1 ::(Int->Int->Int)->(Int1->Int1->Int1) ; oInt1 = oNewtype int1 unInt1 oInt2 ::(Int->Int->Int)->(Int2->Int2->Int2) ; oInt2 = oNewtype int2 unInt2@@ -223,6 +311,12 @@ oNat7 ::(Int->Int->Int)->(Nat7->Nat7->Nat7) ; oNat7 = oNewtype nat7 unNat7 oNatural :: (Integer->Integer->Integer) -> (Natural->Natural->Natural) oNatural = oNewtype natural unNatural+oA :: (Int -> Int -> Int) -> (A -> A -> A); oA = oNewtype mkA unA+oB :: (Int -> Int -> Int) -> (B -> B -> B); oB = oNewtype mkB unB+oC :: (Int -> Int -> Int) -> (C -> C -> C); oC = oNewtype mkC unC+oD :: (Int -> Int -> Int) -> (D -> D -> D); oD = oNewtype mkD unD+oE :: (Int -> Int -> Int) -> (E -> E -> E); oE = oNewtype mkE unE+oF :: (Int -> Int -> Int) -> (F -> F -> F); oF = oNewtype mkF unF fInt1 :: (Int->Int) -> (Int1->Int1) ; fInt1 = fNewtype int1 unInt1 fInt2 :: (Int->Int) -> (Int2->Int2) ; fInt2 = fNewtype int2 unInt2@@ -242,6 +336,12 @@ fNat7 :: (Int->Int) -> (Nat7->Nat7) ; fNat7 = fNewtype nat7 unNat7 fNatural :: (Integer->Integer) -> (Natural->Natural) fNatural = fNewtype Natural unNatural+fA :: (Int -> Int) -> (A -> A); fA = fNewtype mkA unA+fB :: (Int -> Int) -> (B -> B); fB = fNewtype mkB unB+fC :: (Int -> Int) -> (C -> C); fC = fNewtype mkC unC+fD :: (Int -> Int) -> (D -> D); fD = fNewtype mkD unD+fE :: (Int -> Int) -> (E -> E); fE = fNewtype mkE unE+fF :: (Int -> Int) -> (F -> F); fF = fNewtype mkF unF instance Show Int1 where show = show . unInt1 instance Show Int2 where show = show . unInt2@@ -260,6 +360,12 @@ instance Show Nat6 where show = show . unNat6 instance Show Nat7 where show = show . unNat7 instance Show Natural where show (Natural x) = show x+instance Show A where show = show . unA+instance Show B where show = show . unB+instance Show C where show = show . unC+instance Show D where show = show . unD+instance Show E where show = show . unE+instance Show F where show = show . unF instance Read Int1 where readsPrec = readsPrecNewtype int1 instance Read Int2 where readsPrec = readsPrecNewtype int2@@ -278,6 +384,12 @@ instance Read Nat6 where readsPrec = readsPrecNewtype nat6 instance Read Nat7 where readsPrec = readsPrecNewtype nat7 instance Read Natural where readsPrec = readsPrecNewtype natural+instance Read A where readsPrec = readsPrecNewtype mkA+instance Read B where readsPrec = readsPrecNewtype mkB+instance Read C where readsPrec = readsPrecNewtype mkC+instance Read D where readsPrec = readsPrecNewtype mkD+instance Read E where readsPrec = readsPrecNewtype mkE+instance Read F where readsPrec = readsPrecNewtype mkF instance Num Int1 where (+) = oInt1 (+); abs = fInt1 abs@@ -349,7 +461,31 @@ (-) = oNatural (-); signum = fNatural signum (*) = oNatural (*); fromInteger = natural . fromInteger +instance Num A where (+) = oA (+); abs = fA abs+ (-) = oA (-); signum = fA signum+ (*) = oA (*); fromInteger = mkA . fromInteger +instance Num B where (+) = oB (+); abs = fB abs+ (-) = oB (-); signum = fB signum+ (*) = oB (*); fromInteger = mkB . fromInteger++instance Num C where (+) = oC (+); abs = fC abs+ (-) = oC (-); signum = fC signum+ (*) = oC (*); fromInteger = mkC . fromInteger++instance Num D where (+) = oD (+); abs = fD abs+ (-) = oD (-); signum = fD signum+ (*) = oD (*); fromInteger = mkD . fromInteger++instance Num E where (+) = oE (+); abs = fE abs+ (-) = oE (-); signum = fE signum+ (*) = oE (*); fromInteger = mkE . fromInteger++instance Num F where (+) = oF (+); abs = fF abs+ (-) = oF (-); signum = fF signum+ (*) = oF (*); fromInteger = mkF . fromInteger++ instance Real Int1 where toRational (Int1 x) = fromIntegral x % 1 instance Real Int2 where toRational (Int2 x) = fromIntegral x % 1 instance Real Int3 where toRational (Int3 x) = fromIntegral x % 1@@ -367,6 +503,12 @@ instance Real Nat6 where toRational (Nat6 x) = fromIntegral x % 1 instance Real Nat7 where toRational (Nat7 x) = fromIntegral x % 1 instance Real Natural where toRational (Natural x) = fromIntegral x % 1+instance Real A where toRational (A x) = fromIntegral x % 1+instance Real B where toRational (B x) = fromIntegral x % 1+instance Real C where toRational (C x) = fromIntegral x % 1+instance Real D where toRational (D x) = fromIntegral x % 1+instance Real E where toRational (E x) = fromIntegral x % 1+instance Real F where toRational (F x) = fromIntegral x % 1 instance Integral Int1 where quotRem = otNewtype int1 unInt1 quotRem toInteger = toInteger . unInt1@@ -419,6 +561,24 @@ instance Integral Natural where quotRem = otNewtype natural unNatural quotRem toInteger = toInteger . unNatural +instance Integral A where quotRem = otNewtype mkA unA quotRem+ toInteger = toInteger . unA++instance Integral B where quotRem = otNewtype mkB unB quotRem+ toInteger = toInteger . unB++instance Integral C where quotRem = otNewtype mkC unC quotRem+ toInteger = toInteger . unC++instance Integral D where quotRem = otNewtype mkD unD quotRem+ toInteger = toInteger . unD++instance Integral E where quotRem = otNewtype mkE unE quotRem+ toInteger = toInteger . unE++instance Integral F where quotRem = otNewtype mkF unF quotRem+ toInteger = toInteger . unF+ instance Bounded Int1 where maxBound = Int1 0; minBound = Int1 (-1) instance Bounded Int2 where maxBound = Int2 1; minBound = Int2 (-2) instance Bounded Int3 where maxBound = Int3 3; minBound = Int3 (-4)@@ -435,6 +595,12 @@ instance Bounded Nat5 where maxBound = Nat5 4; minBound = Nat5 0 instance Bounded Nat6 where maxBound = Nat6 5; minBound = Nat6 0 instance Bounded Nat7 where maxBound = Nat7 6; minBound = Nat7 0+instance Bounded A where maxBound = A 5; minBound = A 0+instance Bounded B where maxBound = B 5; minBound = B 0+instance Bounded C where maxBound = C 5; minBound = C 0+instance Bounded D where maxBound = D 5; minBound = D 0+instance Bounded E where maxBound = E 5; minBound = E 0+instance Bounded F where maxBound = F 5; minBound = F 0 instance Enum Int1 where toEnum = int1; enumFrom = boundedEnumFrom fromEnum = unInt1; enumFromThen = boundedEnumFromThen@@ -490,6 +656,24 @@ enumFrom (Natural x) = map Natural [x..] enumFromThen (Natural x) (Natural s) = map Natural [x,s..] +instance Enum A where toEnum = mkA; enumFrom = boundedEnumFrom+ fromEnum = unA; enumFromThen = boundedEnumFromThen++instance Enum B where toEnum = mkB; enumFrom = boundedEnumFrom+ fromEnum = unB; enumFromThen = boundedEnumFromThen++instance Enum C where toEnum = mkC; enumFrom = boundedEnumFrom+ fromEnum = unC; enumFromThen = boundedEnumFromThen++instance Enum D where toEnum = mkD; enumFrom = boundedEnumFrom+ fromEnum = unD; enumFromThen = boundedEnumFromThen++instance Enum E where toEnum = mkE; enumFrom = boundedEnumFrom+ fromEnum = unE; enumFromThen = boundedEnumFromThen++instance Enum F where toEnum = mkF; enumFrom = boundedEnumFrom+ fromEnum = unF; enumFromThen = boundedEnumFromThen+ range' :: Enum a => (a,a) -> [a] range' (m,n) = [m..n] @@ -517,6 +701,12 @@ instance Ix Nat6 where range = range'; index = index'; inRange = inRange' instance Ix Nat7 where range = range'; index = index'; inRange = inRange' instance Ix Natural where range = range'; index = index'; inRange = inRange'+instance Ix A where range = range'; index = index'; inRange = inRange'+instance Ix B where range = range'; index = index'; inRange = inRange'+instance Ix C where range = range'; index = index'; inRange = inRange'+instance Ix D where range = range'; index = index'; inRange = inRange'+instance Ix E where range = range'; index = index'; inRange = inRange'+instance Ix F where range = range'; index = index'; inRange = inRange' instance Listable Int1 where list = [0,minBound] instance Listable Int2 where list = listIntegral@@ -535,6 +725,12 @@ instance Listable Nat6 where list = listIntegral instance Listable Nat7 where list = listIntegral instance Listable Natural where list = listIntegral+instance Listable A where list = listIntegral+instance Listable B where list = listIntegral+instance Listable C where list = listIntegral+instance Listable D where list = listIntegral+instance Listable E where list = listIntegral+instance Listable F where list = listIntegral -- | Deprecated. Use 'Word1'. type UInt1 = Word1
stack.yaml view
@@ -1,4 +1,4 @@-resolver: lts-15.5 # or ghc-8.8.3+resolver: lts-17.9 # or ghc-8.10.4 packages: - .
test/types.hs view
@@ -46,6 +46,20 @@ , list `permutation` [minBound..maxBound :: Nat6] , list `permutation` [minBound..maxBound :: Nat7] + , list `permutation` [minBound..maxBound :: A]+ , list `permutation` [minBound..maxBound :: B]+ , list `permutation` [minBound..maxBound :: C]+ , list `permutation` [minBound..maxBound :: D]+ , list `permutation` [minBound..maxBound :: E]+ , list `permutation` [minBound..maxBound :: F]++ , tiers == [[0], [1], [2], [3], [4], [5 :: A]]+ , tiers == [[0], [1], [2], [3], [4], [5 :: B]]+ , tiers == [[0], [1], [2], [3], [4], [5 :: C]]+ , tiers == [[0], [1], [2], [3], [4], [5 :: D]]+ , tiers == [[0], [1], [2], [3], [4], [5 :: E]]+ , tiers == [[0], [1], [2], [3], [4], [5 :: F]]+ , map unX list `permutation` [minBound..maxBound :: Int8] , map unX list `permutation` [minBound..maxBound :: Int4] , map unX list `permutation` [minBound..maxBound :: Int3]