Skip to main content

unify

Function unify 

Source
pub fn unify(
    a: &Type,
    b: &Type,
    subst: &mut Substitution,
) -> Result<(), TypeError>
Expand description

Unify two types under the given substitution, extending the substitution in place when a type variable is bound.

Follows standard Hindley-Milner rules:

  • Type::Error unifies with anything (poison — prevents cascading errors).
  • Type variables are bound after an occurs check.
  • Structural types are unified component-wise.

§Errors

Returns a TypeError if the types are not unifiable.