Map: core / ty
core/src/ty.rs and core/src/ty/ are the type language as data, below the
IR and the checker: the IR’s schemes and
sites name it, and nothing in it reads a unifier or a runtime value.
Types are interned handles: Ty, Row and CompTy each wrap one allocation
of a one-layer node (TyNode, RowNode, CompTyNode) whose children are
handles, made by ty/intern.rs. Equal structures are one allocation, so
== is pointer equality, Hash a structural hash cached at construction,
is_ground a flag cached per node, and height the syntactic nesting height
cached per node (row and curried arrow spines counting as width). The table
holds its entries weakly and sweeps the dead ones in amortized constant time per
insertion. The sharing is the point: the checker answers “same type?”, “free of
variables?” and “how deep?” in O(1), and the checker’s walks over Term
visit each handle once, so shared DAGs stay linear in unique handles rather
than unrolling into trees. OwnedTerm is a Term holding its handle, for a
visited set that outlives the borrows it was reached through.
ty.rs:Ty,CompTy,Grade,Row,Label, the unification-variable newtypes,Var(a variable of any sort) andTerm(a term of any sort);TAG_PREFIX, the sigil of a tag, written once.ty/kind.rs:Kind, the chainnumber ⊂ comparable ⊂ scalar ⊂ data ⊂ any. Its meet ismin;Head::leastgives each head its least kind, and a kind admits the heads whose least kind lies at or below it.ty/scheme.rs:Scheme { ty, tys, comps, rows, grades }, one map per sort from variable toRole<M, B>::{Forall(M), Weak(M), Mu(B)}.Mis what minting a fresh variable of that sort needs (a type’sKind, a row’s deep bit),Bthe sort’s μ-binding:Ty,CompTy, and the uninhabitedNoMufor rows, since a cycle through a row is rooted at a type or computation. Grades are a set, only ever quantified. A role is thus of its variable’s sort by construction.Weakrecords a rank-zero residual for reseeding; ranks themselves live in the checker.Closedis a scheme writing no variable it gives no role, constructed only by settlement,Binders::close(a builtin’s own binder supply) orClosed::new, used by checked deserialisation and raw scheme admission. The child reader checks environment schemes and every recursively linked-module definition scheme, refusing a free variable withDecodeCause::OpenSchemeat its JSON path (transport). Equality is structural. There are no partial schemes or cached environment free variables (schemes leave closed).ty/exec_arg.rs:RefusedArg, the shapesexecve(2)has no argument for, one match on aHead.ty/typed.rs:Typed, aDatumwhose encoding has a ral type derived from its own fields, and the record and variant types ral shows for a Rust type (transport).ty/fmt.rs:DisplayforTyandScheme; oneFmtCtxnames a shared variable the same in every type a diagnostic prints. Producers print asCommand,Returns AorCommand[ν] A; a free grade paired with a type excluding unit printsReturns A, using quantified kinds where known. Scheme quantifiers list only visible grades. Local unit tests build schemes directly to check quantified computation variables and cyclic roots.ty/site.rs: the data of aSite, a boundary’s checked type frozen as a graph of shared nodes (Arc<[Node]>,Shape,Fields,Tail) naming its unit by aUnitId— an OS nonce drawn once per process and a count, so unique in every process that meets it, a baked prelude unit’s included.Fixingsis the session’s table of what each unit’s weakcomparablevariables were fixed to, keyed by(UnitId, var), which a session’s threads share and a new session snapshots (shell-state). The checker builds aSite(typecheck/site.rs), one freshUnitIdper unit, and the runtime walks it against the running session’s table (shell/runtime/admit.rs). Free type/computation nodes, open row tails and free grades retain canonical ids; the first three also retain rank-zero weakness, andSite::checkcertifies that every node reference in a decoded site lies within its slice.
Str, the shared immutable string a Value::String holds, lives in
core/src/data/string.rs, exported as data::Str.