nick8325 / quickcheck

Automatic testing of Haskell programs.
Other
713 stars 119 forks source link

Add COMPLETE pragmas for the pattern synonyms #336

Closed ilkecan closed 2 years ago

ilkecan commented 2 years ago

Hi. Without the added COMPLETE pragmas^1, usage of Fn, Fn2 or Fn3 result in a warning such as

    Pattern match(es) are non-exhaustive
    In an equation for ‘prop_7’: Patterns not matched: (Fun _ _) _

if -Wincomplete-patterns is enabled.

phadej commented 2 years ago

COMPLETE pragmas cause warnings on older GHCs, which support pattern synonyms but not COMPLETE pragma. I'd guard them with CPP:

% cabal build -w ghc-8.0.2
Resolving dependencies...
Build profile: -w ghc-8.0.2 -O1
In order, the following will be built (use -v for more details):
 - QuickCheck-2.14.2 (lib) (first run)
Configuring library for QuickCheck-2.14.2..
Preprocessing library for QuickCheck-2.14.2..
Building library for QuickCheck-2.14.2..
[ 1 of 16] Compiling Test.QuickCheck.Random ( src/Test/QuickCheck/Random.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Random.o )
[ 2 of 16] Compiling Test.QuickCheck.Gen ( src/Test/QuickCheck/Gen.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Gen.o )
[ 3 of 16] Compiling Test.QuickCheck.Gen.Unsafe ( src/Test/QuickCheck/Gen/Unsafe.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Gen/Unsafe.o )
[ 4 of 16] Compiling Test.QuickCheck.Exception ( src/Test/QuickCheck/Exception.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Exception.o )
[ 5 of 16] Compiling Test.QuickCheck.Text ( src/Test/QuickCheck/Text.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Text.o )
[ 6 of 16] Compiling Test.QuickCheck.State ( src/Test/QuickCheck/State.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/State.o )
[ 7 of 16] Compiling Test.QuickCheck.Arbitrary ( src/Test/QuickCheck/Arbitrary.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Arbitrary.o )
[ 8 of 16] Compiling Test.QuickCheck.Modifiers ( src/Test/QuickCheck/Modifiers.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Modifiers.o )
[ 9 of 16] Compiling Test.QuickCheck.Poly ( src/Test/QuickCheck/Poly.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Poly.o )
[10 of 16] Compiling Test.QuickCheck.Function ( src/Test/QuickCheck/Function.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Function.o )

src/Test/QuickCheck/Function.hs:561:1: warning: [-Wunrecognised-pragmas]
    Unrecognised pragma

src/Test/QuickCheck/Function.hs:571:1: warning: [-Wunrecognised-pragmas]
    Unrecognised pragma

src/Test/QuickCheck/Function.hs:578:1: warning: [-Wunrecognised-pragmas]
    Unrecognised pragma
[11 of 16] Compiling Test.QuickCheck.Property ( src/Test/QuickCheck/Property.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Property.o )
[12 of 16] Compiling Test.QuickCheck.Monadic ( src/Test/QuickCheck/Monadic.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Monadic.o )
[13 of 16] Compiling Test.QuickCheck.Test ( src/Test/QuickCheck/Test.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Test.o )
[14 of 16] Compiling Test.QuickCheck.Features ( src/Test/QuickCheck/Features.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/Features.o )
[15 of 16] Compiling Test.QuickCheck.All ( src/Test/QuickCheck/All.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck/All.o )
[16 of 16] Compiling Test.QuickCheck  ( src/Test/QuickCheck.hs, /code/other-haskell/quickcheck/dist-newstyle/build/x86_64-linux/ghc-8.0.2/QuickCheck-2.14.2/build/Test/QuickCheck.o )

EDIT: looks like COMPLETE pragmas was added in GHC-8.2: https://downloads.haskell.org/~ghc/8.2.2/docs/html/users_guide/8.2.1-notes.html#language

sjakobi commented 2 years ago

@nick8325 This should fix my problem reported in #344. Could this be merged?! :)

nick8325 commented 2 years ago

Thanks @ilkecan!