Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Subtyping

A <: B declares A is a subtype of B. Two universal bounds frame the lattice: A <: Top and Bot <: A hold for every A.

Beyond the declared <: graph, the substrate has three built-in subtyping sources (oxc-check/src/infer.rs::types_compatible):

  • Numeric tower: Nat <: Int <: Real and Nat <: Int <: Decimal. Money is not in the tower — there is no implicit Int → Money; Money only arises through the result-side widening of monetary arithmetic (Numeric tower and coercion), Money ▷ Decimal ▷ Real ▷ Int.
  • Covariant collections: List<A> <: List<B> and Option<A> <: Option<B> iff A <: B (written [A]/A?).
  • Invariant elsewhere: tuples, fn(…) -> _, and generic applications subtype only by equality.

Real, Decimal, and Money are exact arbitrary-precision rationals (BigRational); source numeric literals parse to exact rationals with no f64 round-trip, so 0.1 + 0.2 == 0.3 (RFD 0016, oxc-reasoning/src/compile/value.rs).