- -- For convenience we enforce the stronger invariant that no
- -- meta type variable is the RHS of a function equality
-reOrient (FunCls {}) _ = False -- Fun/Other on rhs
-
-reOrient (VarCls tv1) (FunCls {}) = not (isMetaTyVar tv1)
-reOrient (VarCls {}) (OtherCls {}) = False
-reOrient (VarCls {}) (VarCls {}) = False
-
-{-
--- Variables-variables are oriented according to their kind
--- so that the following property has the best chance of
--- holding: tv ~ xi
--- * If tv is a MetaTyVar, then typeKind xi <: typeKind tv
--- a skolem, then typeKind xi = typeKind tv
-
- | k1 `eqKind` k2 = False
- | otherwise = k1 `isSubKind` k2
- where
- k1 = tyVarKind tv1
- k2 = tyVarKind tv2
--}
+reOrient _untch (FunCls {}) _ = False -- Fun/Other on rhs
+
+reOrient _untch (VarCls tv1) (FunCls {}) = not $ isMetaTyVar tv1
+ -- Put function on the left, *except* if the RHS becomes
+ -- a meta-tyvar; see invariant on CFunEqCan
+ -- and Note [No touchables as FunEq RHS]
+
+reOrient _untch (VarCls tv1) (FskCls {}) = not $ isMetaTyVar tv1
+ -- Put flatten-skolems on the left if possible:
+ -- see Note [Loopy Spontaneous Solving, Example 4] in TcInteract
+
+reOrient _untch (VarCls {}) (OtherCls {}) = False
+reOrient _untch (VarCls {}) (VarCls {}) = False
+
+reOrient _untch (FskCls {}) (VarCls tv2) = isMetaTyVar tv2
+ -- See Note [Loopy Spontaneous Solving, Example 4] in TcInteract
+
+reOrient _untch (FskCls {}) (FskCls {}) = False
+reOrient _untch (FskCls {}) (FunCls {}) = True
+reOrient _untch (FskCls {}) (OtherCls {}) = False