Skip to main content

Module subtyping

Module subtyping 

Source
Expand description

Depth subtyping with semantic-scalar narrowing.

is_assignable(graph, sub, sup) returns true when a value valid under sub is also valid under sup.

Records are compared by exact structural match: field counts must agree, and for each position the field names must be equal and the bodies mutually compatible per is_assignable. Width-subtyping and field reordering are intentionally rejected because [SchemaValue::Record] values are positional — they do not carry field names at runtime — so reading a “wider” record as a narrower one would silently re-interpret values by index.

Variant payloads use invariant subtyping: matching cases either both lack a payload, or both carry payloads that are assignable in both directions.

Functions§

is_assignable
Is sub assignable to sup inside graph?
is_equivalent_cross_graph
Structural type equivalence across two (possibly different) graphs.