Improve the equality-floating story (again), to fix Trac #8644
authorSimon Peyton Jones <simonpj@microsoft.com>
Fri, 3 Jan 2014 16:04:04 +0000 (16:04 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Fri, 3 Jan 2014 16:04:04 +0000 (16:04 +0000)
commit9e10d1883d7ea5ea422cda79b426f51d2b59b14d
treef06186c670f1a5a3d3fa4fe2a07b0f7deb3cf579
parent5dffb4ac14b53362ebe9a67c5c6a01f9c9c25229
Improve the equality-floating story (again), to fix Trac #8644

We float equalities out of implications whose 'givens' include equalities.
But it's a bit tricky knowing whether some givens do or do not include
equalities, as #8644 shows.  There the given has type 'c' (which might
have equalities), but we discover that 'c ~ ()', which definitely doesn't.

In short, we must look at the givens *after* normalisation, not before.
Moreover, something similar happens in approximateWC, where we need
to ask whether an implication has given equalities.

This patch does the job:

* Add a Boolean field inert_no_eqs to InertCans, which records
  whether we've added a non-constant equality

* Add a field ic_no_eqs to Implication, which records whether the
  ic_given binders include any equalities

* Get rid of Inst.hasEqualities altogether

On the way I did some un-forced refactoring

* Introduce the auxiliary function TcCanonical.flattenNestedFamApp

* Kill off FamHeadMap and PredMap in favour of
  the new FunEqMap and DictMap respectively
compiler/typecheck/Inst.lhs
compiler/typecheck/TcCanonical.lhs
compiler/typecheck/TcInteract.lhs
compiler/typecheck/TcRnTypes.lhs
compiler/typecheck/TcRules.lhs
compiler/typecheck/TcSMonad.lhs
compiler/typecheck/TcSimplify.lhs
compiler/typecheck/TcUnify.lhs