Fix bug in hasFixedRuntimeRep check in matchExpectedFunTys
Ticket: #26528 (closed)
This MR fixes a bug in the representation-polymormorphism check in GHC.Tc.Utils.Unify.matchExpectedFunTys.
The problem was that we put the coercion resulting from hasFixedRuntimeRep in the wrong place, leading to the Core Lint error reported in #26528 (closed).
The change is that we have to be careful when using mkWpFun: it expects both the expected and actual argument types to have a syntactically fixed RuntimeRep, as explained in Note [WpFun-FRR-INVARIANT] in GHC.Tc.Types.Evidence.
On the way, this patch improves some of the commentary relating to other usages of mkWpFun in the compiler, in particular in the view pattern case of tc_pat. No functional changes, but some stylistic changes to make the code more readable, and make it easier to understand how we are upholding the WpFun-FRR-INVARIANT.
TODO:
-
Rebase over !14793 (closed) once that lands. -
Incorporate changes from @simonpj that we discussed together.