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!
Showing with 446 additions and 322 deletions