Make `singleConstructor` cope with pattern synonyms
authorSebastian Graf <sebastian.graf@kit.edu>
Wed, 3 Apr 2019 16:53:32 +0000 (18:53 +0200)
committerMarge Bot <ben+marge-bot@smart-cactus.org>
Mon, 8 Apr 2019 19:06:15 +0000 (15:06 -0400)
commitd236d9d0f4f3be0641933b959dde14a065acd37f
tree9e0bcdde03bd8be1b2517bedcdb839e028e90801
parent4dda2270d26017eadddd99ed567aacf41c2913b9
Make `singleConstructor` cope with pattern synonyms

Previously, `singleConstructor` didn't handle singleton `COMPLETE` sets
of a single pattern synonym, resulting in incomplete pattern warnings
in #15753.

This is fixed by making `singleConstructor` (now named
`singleMatchConstructor`) query `allCompleteMatches`, necessarily making
it effectful. As a result, most of this patch is concerned with
threading the side-effect through to `singleMatchConstructor`.

Unfortunately, this is not enough to completely fix the original
reproduction from #15753 and #15884, which are related to function
applications in pattern guards being translated too conservatively.
compiler/deSugar/Check.hs
testsuite/tests/pmcheck/should_compile/T15753a.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/T15753b.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/T15884.hs [new file with mode: 0644]
testsuite/tests/pmcheck/should_compile/all.T