COMPLETE pragmas for enhanced pattern exhaustiveness checking
authorMatthew Pickering <matthewtpickering@gmail.com>
Wed, 18 Jan 2017 13:25:30 +0000 (13:25 +0000)
committerMatthew Pickering <matthewtpickering@gmail.com>
Thu, 26 Jan 2017 00:22:46 +0000 (00:22 +0000)
commit1a3f1eebf81952accb6340252816211c7d391300
tree03fbe6fac6518c3da73282266833941d76b34736
parent078c21140d4f27e586c9fa893d4ac94d28d6013c
COMPLETE pragmas for enhanced pattern exhaustiveness checking

This patch adds a new pragma so that users can specify `COMPLETE` sets of
`ConLike`s in order to sate the pattern match checker.

A function which matches on all the patterns in a complete grouping
will not cause the exhaustiveness checker to emit warnings.

```
pattern P :: ()
pattern P = ()

{-# COMPLETE P #-}

foo P = ()
```

This example would previously have caused the checker to warn that
all cases were not matched even though matching on `P` is sufficient to
make `foo` covering. With the addition of the pragma, the compiler
will recognise that matching on `P` alone is enough and not emit
any warnings.

Reviewers: goldfire, gkaracha, alanz, austin, bgamari

Reviewed By: alanz

Subscribers: lelf, nomeata, gkaracha, thomie

Differential Revision: https://phabricator.haskell.org/D2669

GHC Trac Issues: #8779
51 files changed:
compiler/basicTypes/ConLike.hs
compiler/deSugar/Check.hs
compiler/deSugar/Desugar.hs
compiler/deSugar/DsMeta.hs
compiler/deSugar/DsMonad.hs
compiler/deSugar/PmExpr.hs
compiler/deSugar/TmOracle.hs
compiler/hsSyn/HsBinds.hs
compiler/iface/IfaceSyn.hs
compiler/iface/MkIface.hs
compiler/iface/TcIface.hs
compiler/main/HscTypes.hs
compiler/main/TidyPgm.hs
compiler/parser/Lexer.x
compiler/parser/Parser.y
compiler/parser/RdrHsSyn.hs
compiler/rename/RnBinds.hs
compiler/typecheck/TcBinds.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcRnMonad.hs
compiler/typecheck/TcRnTypes.hs
compiler/vectorise/Vectorise/Monad.hs
docs/users_guide/glasgow_exts.rst
testsuite/tests/pmcheck/complete_sigs/Completesig03.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/Completesig03.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/Completesig03A.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/Makefile [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/all.T [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig01.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig02.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig02.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig04.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig04.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig05.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig06.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig06.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig07.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig07.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig08.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig09.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig10.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig10.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig11.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig11.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig12.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig13.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig14.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig14.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig15.hs [new file with mode: 0644]
testsuite/tests/pmcheck/complete_sigs/completesig15.stderr [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/all.T