Assign and . The application s y x forces for a fresh type ; applying f to that result forces . No further equations identify these four type variables. The principal type is therefore
k :: (u -> v -> w) -> v -> (w -> r) -> u -> r
k s x f y = f (s y x)
Every compatible typing is an instance of this one, because type inference imposed precisely the two application constraints and no class constraints.
Principal type 2026-10-25
A principal type is a most general valid type scheme: every other valid typing of the expression is obtained by substituting types for its quantified type variables, subject to any declared class constraints. For example, \s x f y -> f (s y x) has type (u -> v -> w) -> v -> (w -> r) -> u -> r; the application constraints require precisely these connections and no equality between the four type variables. A concrete typing is an instance, not evidence that the expression needs that particular type.