- Nothing | any (inRnEnvR rn_env) (varSetElems (tyVarsOfType ty2))
- -> Nothing -- Occurs check
- | not (typeKind ty2 `isSubKind` tyVarKind tv1)
- -> Nothing -- Kind mis-match
- | otherwise
- -> Just (extendVarEnv subst tv1 ty2)
-
- Just ty1' | tcEqTypeX (nukeRnEnvL rn_env) ty1' ty2
+ Nothing -- No existing binding
+ | any (inRnEnvR rn_env) (varSetElems (tyVarsOfType ty2))
+ -> Nothing -- Occurs check
+ | not (typeKind ty2 `isSubKind` tyVarKind tv1)
+ -> Nothing -- Kind mis-match
+ | otherwise
+ -> Just (extendVarEnv subst tv1 ty2)
+
+ Just ty1' -- There is an existing binding; check whether ty2 matches it
+ | tcEqTypeX (nukeRnEnvL rn_env) ty1' ty2