Revert "Simplify the plumbing for checkValidTyCl"

This reverts commit 174577912de7a21b8fe01881a28f5aafce02b92e.

This is part of the fix for #8607. Only reverting RdrHsSyn.lhs.

Conflicts:

	compiler/parser/RdrHsSyn.lhs
	compiler/typecheck/TcTyClsDecls.lhs
Fix #8607.

The solution (after many false starts) is to change the behavior of
hsLTyClDeclBinders. The idea is that the locations of the names that
the parser generates should really be the names' locations, unlike
what was done in 1745779... But, when the renamer is creating Names
from the RdrNames, the locations stored in the Names should be the
declarations' locations. This is now achieved in hsLTyClDeclBinders,
which returns [Located name], but the location is that of the
*declaration*, not the name itself.
Add hook for splicing in renamer

With the recent modifications to the TH infrastructure, many splices are now
expanded in the renamer rather than the typechecker. This means that tools
which inspect the renamed tree don't get to see the original splices. Added a
new hook which gets called before such a splice gets expanded, analogous to the
runQuasiQuoteHook.
Define mkTcNomReflCo = TcRefl Nominal, and use it all over

This patch doesn't include the changes to TcCanonical and TcSMonad,
which are a bigger follow-up patch, so it is tightly coupled to the
follow-up.
Re-factor TcCanonical (again), fixes Trac #8603

This is a substantial refactoring of the canonicaliser. The proximate
cause was that we were sometimes failing to correctly orient a
tyvar/tyvar equality (x ~ y), because the kind of x or y was not fully
zonked at the moment we compared them.  That in turn led me to look
closely at the way that canEvNC (which decomposes equalities) worked.

* The big change is that the 'reOrient' and 'classify' functions are gone,
  along with classify's 'TypeClassifier' return type.  Instead the
  re-orientation is built into canEqNC.  When we find a type variable
  we divert into canEqTyVar, and so on, very much as in TcUnify.

* TcCanonical.canEqTyVar, canEqLeafFun, etc now carry a SwapFlag (to
  reduce duplication), just as in TcUnify; now SwapFlag itself is
  defined in BasicTypes

* I renamed TcSMonad.rewriteCtFlavor to rewriteEvidence,

* I added a new specialised version of rewriteEvidence, called
  TcSMonad.rewriteEqEvidence.  It is easier to use, and removes
  the crafty but brain-mangling higher order casts that we were
  using before.

The result is not exactly simpler, but it's pretty clear and, I think,
significantly more efficient.  And it fixes Trac #8603!
Comments only
Comments only
Merge latest upstream GHC changes