← writing

arity-sharded crates

summary: tachyon's workspace is one crate per arity class. the cleanest split i have tried.

ThePlatform ThePlatform: proving the shared runtime in production work: 2023 technical note

Core idea: the Rust workspace was split by semantic arity because that made the build graph match the language dispatch graph.

The workspace is one crate per arity class - monad, dyad1..dyad4, triad, tetrad1..tetrad3, plus the reactor and parser registrations - because that is the structure the language already had. The workspace is just being honest about it.

The non-obvious win is in monomorphisation. Generic kernels are instantiated once per element type per arity, in their own crate, and the resulting code lives in one object file. Without arity-sharding, the same generic instantiation appears in every crate that calls into a primitive, the linker does what it can about the duplicates, and it never does enough. By cutting the workspace along the same line the dispatch already cuts, the duplication never happens.

The tax is that someone reading the codebase has to learn arity classification before anything makes sense. Newcomers ask, fairly, "why is + defined in two places". The answer is short - "it is two primitives sharing a glyph" - but it has to be given. I would still shard by arity.