Commit a836b69c authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Improve orientation

I came across some stupid re-orientation, when debugging something else.
For example, we were re-orienting

    t ~ fsk
to
   fsk ~ t
where fsk is a flatten *skolem* and t is a meta type varaible.
The logic was just wrong.
parent dff0e99d
......@@ -1008,15 +1008,18 @@ reOrient (FunCls {}) _ = False -- Fun/Other on rhs
reOrient (VarCls {}) (FunCls {}) = True
reOrient (VarCls {}) (OtherCls {}) = False
reOrient (VarCls tv1) (VarCls tv2)
| not (k2 `isSubKind` k1), k1 `isSubKind` k2 = True -- Note [Kind orientation for CTyEqCan]
-- in TcRnTypes
| not (isMetaTyVar tv1), isMetaTyVar tv2 = True
| not (isFlatSkolTyVar tv1), isFlatSkolTyVar tv2 = True -- Note [Eliminate flat-skols]
| otherwise = False
| k1 `eqKind` k2 = tv2 `better_than` tv1
| k1 `isSubKind` k2 = True -- Note [Kind orientation for CTyEqCan]
| otherwise = False -- in TcRnTypes
where
k1 = tyVarKind tv1
k2 = tyVarKind tv2
-- Just for efficiency, see CTyEqCan invariants
tv2 `better_than` tv1
| isMetaTyVar tv1 = False -- Never swap a meta-tyvar
| isFlatSkolTyVar tv1 = isMetaTyVar tv2
| otherwise = isMetaTyVar tv1 || isFlatSkolTyVar tv2
-- Note [Eliminate flat-skols]
------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment