Add `PatSynSigSkol` and modify `PatSynCtxt`
authorRik Steenkamp <rik@ewps.nl>
Wed, 23 Mar 2016 15:17:27 +0000 (16:17 +0100)
committerBen Gamari <ben@smart-cactus.org>
Thu, 24 Mar 2016 09:53:27 +0000 (10:53 +0100)
commit997312b04c56017197250096d61f3e8fab502319
treed3016894157110c7751ed01c3be9e617ca61884b
parent8048d51be0676627b417c128af0b0c352b75c537
Add `PatSynSigSkol` and modify `PatSynCtxt`

As the type of a pattern synonym cannot in general be represented by a
value of type Type, we cannot use a value `SigSkol (PatSynCtxt n) (Check
ty)` to represent the signature of a pattern synonym (this causes
incorrect signatures to be printed in error messages). Therefore we now
represent it by a value `PatSynSigSkol n` (instead of incorrect
signatures we simply print no explicit signature).

Furthermore, we rename `PatSynCtxt` to `PatSynBuilderCtxt`, and use
`SigSkol (PatSynBuilderCtxt n) (Check ty)` to represent the type of a
bidirectional pattern synonym when used in an expression context.
Before, this type was represented by a value `SigSkol (PatSynCtxt n)
(Check ty)`, which caused incorrect error messages.

Also, in `mk_dict_err` of `typecheck\TcErrors.hs` we now distinguish
between all enclosing implications and "useful" enclosing implications,
for better error messages concerning pattern synonyms. See `Note [Useful
implications]`.

See the Phabricator page for examples.

Reviewers: mpickering, goldfire, simonpj, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

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

GHC Trac Issues: #11667
12 files changed:
compiler/basicTypes/PatSyn.hs
compiler/typecheck/TcErrors.hs
compiler/typecheck/TcPatSyn.hs
compiler/typecheck/TcRnTypes.hs
compiler/typecheck/TcSimplify.hs
compiler/typecheck/TcType.hs
compiler/typecheck/TcValidity.hs
testsuite/tests/patsyn/should_fail/T10873.stderr
testsuite/tests/patsyn/should_fail/T11039.stderr
testsuite/tests/patsyn/should_fail/T11667.hs [new file with mode: 0644]
testsuite/tests/patsyn/should_fail/T11667.stderr [new file with mode: 0644]
testsuite/tests/patsyn/should_fail/all.T