Skip to main content

Module unify

Module unify 

Source
Expand description

Unification engine for the bidirectional type checker.

Provides Robinson unification for InferType, which extends LogosType with type variables for the inference pass. After inference, UnificationTable::zonk converts InferType → LogosType. Unsolved variables become LogosType::Unknown, preserving the existing codegen safety net.

§Architecture

InferType  ←  inference pass (this module + check.rs)
    │
    │  zonk (after inference)
    ▼
LogosType  →  codegen (unchanged)

Structs§

TyVar
A type variable used during inference.
TypeScheme
A quantified polymorphic type.
TypeScope
Where the names in a written type are looked up while converting it: the program’s registry (so a user struct or enum is a UserDefined, not Unknown) and the type parameters in scope, each standing for the type it is currently bound to.
UnificationTable
Union-Find table implementing Robinson unification with occurs check.

Enums§

InferType
Inference-time type representation.
TypeError
A type error detected during unification or checking.

Functions§

infer_to_logos
Convert a zonked InferType to LogosType.
unify_numeric
Numeric promotion: Float wins; Int + Int = Int; Nat + Nat = Nat; Byte + Byte = Byte; Byte + Int (literal context) = Byte; otherwise error.