Better solving for representational equalities
authorSimon Peyton Jones <simonpj@microsoft.com>
Tue, 17 Oct 2017 15:32:25 +0000 (16:32 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Wed, 18 Oct 2017 07:31:01 +0000 (08:31 +0100)
commit5a66d574890ed09859ca912c9e0969dba72f4a23
tree445c5045583108be2f54815e163b9bab98e8e93d
parent74cd1be0b2778ad99566cde085328bde2090294a
Better solving for representational equalities

This patch adds a bit of extra solving power for representational
equality constraints to fix Trac #14333

The main changes:

* Fix a buglet in TcType.isInsolubleOccursCheck which wrongly
  reported a definite occurs-check error for (a ~R# b a)

* Get rid of TcSMonad.emitInsolubles.  It had an ad-hoc duplicate-removal
  piece that is better handled in interactIrred, now that insolubles
  are Irreds.

  We need a little care to keep inert_count (which does not include
  insolubles) accurate.

* Refactor TcInteract.solveOneFromTheOther, to return a much simpler
  type.  It was just over-complicated before.

* Make TcInteract.interactIrred look for constraints that match
  either way around, in TcInteract.findMatchingIrreds

This wasn't hard and it cleaned up quite a bit of code.
compiler/typecheck/TcCanonical.hs
compiler/typecheck/TcInteract.hs
compiler/typecheck/TcSMonad.hs
compiler/typecheck/TcType.hs
testsuite/tests/typecheck/should_compile/T14333.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/all.T
testsuite/tests/typecheck/should_fail/FrozenErrorTests.hs