Draft: Ensure inferred patterns have a fixed RuntimeRep
This patch adds a field ir_frr
to the InferResult
datatype,
holding a value of type Maybe FRROrigin
. When this value is not
Nothing
, this means that we must fill the ir_ref
field with a type
which has a fixed RuntimeRep.
When it comes time to fill such an ExpType
, we ensure that the type
has a fixed RuntimeRep by performing a representation-polymorphism
check with the given FRROrigin
This is similar to what we already do to ensure we fill an Infer
ExpType
with a type of the correct TcLevel
.
I had to move fillInferResult
from GHC.Tc.Utils.TcMType
to
GHC.Tc.Utils.Unify
to avoid creating cyclic imports.
This patch also changes the code in matchExpectedFunTys
to make use
of the coercions, which is now possible thanks to the previous change.
This implements PHASE 2 of FixedRuntimeRep in some situations.
For example, the test cases T13105
and T17536b
are now both accepted.
I've also taken the opportunity to change the type returned by
hasFixedRuntimeRep
, so that it directly answers with the most useful
coercion (which is a GRefl
), as opposed to the kind coercion,
and to use MCoercion
instead of Maybe
as suggested by @rae.