Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add COMPLETE pragmas for the pattern synonyms #336

Merged
merged 1 commit into from
May 6, 2022

Conversation

ilkecan
Copy link
Contributor

@ilkecan ilkecan commented Oct 27, 2021

Hi. Without the added COMPLETE pragmas1, 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.

Footnotes

  1. https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/pragmas.html#complete-pragmas

@ilkecan ilkecan marked this pull request as ready for review October 27, 2021 09:14
@phadej
Copy link
Contributor

phadej commented Oct 27, 2021

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

@@ -558,6 +558,9 @@ instance Functor (Fun a) where
pattern Fn :: (a -> b) -> Fun a b
#endif
pattern Fn f <- (applyFun -> f)
#if __GLASGOW_HASKELL__ >= 802
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@sjakobi
Copy link

sjakobi commented May 6, 2022

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

@nick8325 nick8325 merged commit 71668ed into nick8325:master May 6, 2022
@nick8325
Copy link
Owner

nick8325 commented May 6, 2022

Thanks @ilkecan!

@konsumlamm konsumlamm mentioned this pull request Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants