Type system

This document specifies Hale's type system: what types exist, how they relate, what the compiler verifies. Where the grammar (grammar.ebnf) tells you what's…

Reference material, synced from the compiler repo’s spec/. The guide is the gentler path in.

This document specifies Hale’s type system: what types exist, how they relate, what the compiler verifies. Where the grammar (grammar.ebnf) tells you what’s syntactically valid, this document tells you what’s meaningfully valid.

Primitive types

Section titled “Primitive types”
Type Repr (v0 codegen) Notes
Int i64 Signed; default for integer literals
U64 i64 A 64-bit unsigned integer, 0 through 2^64 - 1 (GH #2121): the same 8 bytes as an Int, read as unsigned. An integer literal whose place is a U64 is one, and a decimal literal past Int’s max is one by itself (range-checked where it is written). + - * / % never wrap: an overflow or a division by zero is a runtime violation; U64::wrapping_* wrap modulo 2^64 and U64::checked_* fail instead. Unsigned division, comparison and >>. Never mixes with Int or another type implicitly (§ U64). Replaces the reserved Uint, which the checker refused.
I32, U32, I16, U16, I8, U8 i32, i16, i8 The fixed-width integers (GH #2132, F.64), signed two’s complement and unsigned, at their declared width in every layout: a record, a bounded element, a locus field, a topic payload, a local. An integer literal whose place is one is one, range-checked where it is written. + - * / % never wrap: an overflow or a division by zero is a runtime violation; T::wrapping_* wrap and T::checked_* fail instead. One widens implicitly only where nothing is lost (into a wider type of the same signedness, an unsigned one into a strictly wider signed one, anything into Int); a narrowing is a cast with an or, and operands never widen (§ Fixed-width integers).
Float f64 IEEE 754 double; default for float literals
Decimal<S>, Decimal i128 Fixed point: an i128 mantissa at the scale S (mantissa × 10^-S), S an integer literal from 0 to 18 that is part of the type; plain Decimal is Decimal<9>, the same type (2026-10-12, § Decimal). Every scale is the one 16-byte, 16-aligned layout. Distinct from Float at the type level; suffix d on literals (1.50d). A literal holds no more places than the scale of the place it flows into (a check error at the literal otherwise, never a truncation); + - % are exact, * and / truncate toward zero at the scale; two scales never mix, and d.rescale(T) converts. Real arbitrary-precision deferred.
U256, I256 i256 The 256-bit integers (GH #1934), unsigned and two’s complement signed: 32 bytes at the target’s i256 alignment (16 on x86-64 and aarch64). No literal: U256::from_int(n), U256::parse(s) or ... (decimal or 0x hex), U256::from_be_bytes(b) or ... (32 bytes) make one. + - * / % never wrap: an overflow or a division by zero is a runtime violation, and U256::checked_* / mul_div fail instead. Never mixes with Int or another type implicitly (§ U256 and I256).
String ptr (NUL-terminated) UTF-8 bytes, C-style NUL-terminated. Single-pointer ABI to fit return-by-value through the m49 calling convention. Embedded NUL truncates — use Bytes for binary content. len(s) is a strlen, which a local or parameter remembers per value it holds (spec/stdlib.md § Linear byte scanning). Allocated in the caller’s arena (or the lazy global payload arena for stdlib returns whose lifetime needs to outlive the call).
Bool i1 true / false
Time i64 Nanoseconds since the Unix epoch, UTC (GH #607, 2026-09-14). A literal is ISO-8601 between backticks — `2026-05-08T12:00:00Z`, an optional fraction of one to nine digits, an optional Z; an offset such as +01:00 is a compile error, never read as UTC, and so is a day past its month’s length (2099-02-30, 2100-02-29), never rolled into the next month — and is parsed at check time. Declared by the stdlib (type Time = point Duration;, GH #1076 U4, spec/units.md § The stdlib’s time catalogue): a point over Duration with no origin:, so the unit dialect’s algebra of points is its arithmetic: Time ± Duration → Time, Duration + Time → Time, Time − Time → Duration; anything else with a Time operand is refused, naming both. Orders and compares as an instant. to_string / println render ISO-8601, the fraction only when it is not zero. Before the epoch is negative, not an error. It holds 1677-09-21T00:12:43.145224192Z through 2262-04-11T23:47:16.854775807Z: a literal past either end is a check error at the literal, parse_time of one is its ParseError, and time_from_unix or Time ± Duration past either end is a runtime violation (spec/stdlib.md std::time), never a wrapped instant. On the wire and in a struct it is the same 8 bytes as Int; over FFI it is i64. std::time::current() reads the wall clock as one; iso8601, parse_time, unix, nanos, from_nanos, time_from_unix convert. Was a string-shaped placeholder until v0.20.0.
Duration i64 Nanoseconds. Declared by the stdlib (type Duration = quantity Int in ns;, GH #1076 U4, spec/units.md § The stdlib’s time catalogue): a quantity of the time catalogue (ns us ms s min h day), whose literals are its units’ (5s, 100ms, 2min, 1day), each its count of nanoseconds. Arithmetic is the unit dialect’s algebra of quantities: Duration ± Duration → Duration; scalar scale Int * Duration (either order) produces Duration (the runtime-computed-delay shape, ms * 1ms); Duration / Duration → Int, the quotient of the two counts (1h / 1min is 60); Duration / Int → Duration, the integer division for a runtime divisor, and for an integer literal other than one a narrowing whose or says what becomes of the remainder (timeout / 2 or floor, or ceil, or <value>; a bare timeout / 2 is refused, U4’s second correction); Duration * Duration and % are refused, naming both. Keeps its representation: prints its nanoseconds (1500000000ns), tags a topic field u, is its own FFI class. d.in(u), d.split(u) and Duration(x) are the dialect’s conversions (spec/units.md § Conversions).
Bytes (m89) ptr → [i64 len][u8 data[len]] Binary-safe. Single-pointer ABI like String, but the underlying blob carries an explicit length prefix so embedded NUL bytes don’t truncate. len(b) reads the prefix. Distinct from String at the type level; the typechecker keeps them apart. Operations: std::io::fs::read_bytes (m89), Stream.send_bytes (m89), Stream.recv_bytes (Phase 2g; both fallible(IoError) since #209), std::bytes::at / std::bytes::slice / std::bytes::from_string (Phase 2g), std::str::from_bytes for the inverse direction (Phase 2g).
BytesView (F.30) lotus_view_t { src: ptr, epoch: i64 } (16 bytes, by-value; SysV AMD64 returns in rax/rdx) Non-owning view over a BytesBuilder’s buffer. Returned by BytesBuilder.view(). src is the builder pointer; epoch snapshots the builder’s mutation_epoch. The underlying Bytes-shaped data pointer (buf - 8) is recomputed at read time by lotus_bytes_view_data, so the view itself doesn’t allocate or carry the data pointer. Coerces implicitly to Bytes at function-argument READ positions (e.g. std::bytes::at(view, i), len(view), user-defined fallible-fn args, self/external/interface method args, monomorphized-generic args); codegen emits a call to lotus_bytes_view_data which checks the stamped epoch against the builder’s live epoch, panics on mismatch (F.30b mutation-while-view-live guard), and returns the recomputed data ptr on the OK path. Rejected at Bytes-typed storage sites — callers wanting owned storage must std::bytes::clone(view) for a deep-copy into the caller’s arena. Storage typed BytesView is allowed; a String / Bytes literal at a BytesView/StringView storage default is wrapped via lotus_view_from_static_data with epoch == LOTUS_VIEW_EPOCH_STATIC = -1 — the unpack helper sees the static sentinel and returns src directly without an epoch check (the literal lives in the global string table at program-lifetime, so there’s no source builder to check against). 2026-05-22 PM: ABI compacted from a 24-byte heap-allocated struct to this 16-byte by-value shape; no arena allocation per view() call.
StringView (F.30) lotus_view_t { src: ptr, epoch: i64 } (16 bytes, by-value) Non-owning view over a BytesBuilder’s NUL-terminated buffer. Returned by BytesBuilder.text_view(). Symmetric companion to BytesView: same layout, same epoch guard, same static sentinel. Coerces to String at read sites via lotus_str_view_data (which recomputes the C-string pointer as b->buf — the buf[len] == '\0' invariant maintained by every mutating op makes this well-formed); rejected at String-typed storage; std::str::clone(view) upgrades to owned.
BytesMut (#3) raw {ptr, len} window (by-value; no [i64 len] prefix) A non-owning raw writable/readable window — distinct from Bytes (which carries a length prefix the handle points into) because BytesMut is a bare {ptr, len} pair over memory owned elsewhere. Handed out by the zero-copy ring producer (Topic.write(max) { w => … } binds w: BytesMut over the reserved slot) and by std::io::MirrorRing (readable() / writable() return a BytesMut over the live / free region). Read it zero-copy with the _raw siblings of the binary-pack family (std::bytes::read_* / at / find_byte accept a BytesMut directly — length is the window length, not a prefix); write into it with the binary-pack writers (std::bytes::write_*). The window is valid only until the next ring commit / mirror advance — no epoch guard, so the lifetime discipline is the caller’s.

FnPtr (m80): First-class function values, type-spelled fn(T1, T2) -> R (or fn(T1, T2) for void-returning; fn(T1, T2) -> () is the same type, in a signature too, GH #2005). LLVM lowering is ptr (raw fn pointer); calls go through build_indirect_call with an LLVM FunctionType synthesized from the FnPtr’s args/ret at the call site. The implicit __caller_arena: ptr first param of every user fn (m49 calling convention) is also expected on the FnPtr’s call ABI — indirect calls prepend it before user-visible args. See stdlib/io_tcp.hl for the canonical use: Listener.on_connection: fn(std::io::tcp::Stream).

FFI-portable subset (Stage-1 FFI): the primitive type set above carries an additional axis of distinction at the @ffi("c") boundary: which types have a stable C-ABI mapping. Int / Float / Bool / Duration / Time / String / Bytes / BytesView / StringView may appear in @ffi parameter and return positions, and so may U64 (a C uint64_t; a JS number at @ffi("js"), as an Int is) and the fixed-width integers (int32_t … uint8_t; a JS number); Decimal (any scale) / U256 / I256 are typecheck-rejected (platform-variable ABI; a 256-bit integer crosses as its 32 big-endian bytes, U256::to_be_bytes). See spec/ffi.md for the full marshalling table and the lifetime contract.

Float comparison

Section titled “Float comparison”

Float compares by IEEE 754. ==, <, <=, > and >= are the ordered comparisons: each is false when either operand is NaN, so nan == nan is false. != is the negation of == and is true when either operand is NaN — nan != nan and nan != 1.0 are both true (codegen fcmp une; until 2026-10-12 it lowered to the ordered fcmp one and answered both false). x != x is therefore the NaN test, the same one std::math::is_nan makes. The two zeros are equal (-0.0 == 0.0) and neither orders below the other; the infinities order beyond every finite value and equal themselves. A match arm on a Float literal is an == test, so it never matches a NaN scrutinee.

The value builtins follow IEEE 754-2019: min(a, b) / max(a, b) on Float are minimum / maximum — a NaN on either side makes the result NaN, and -0.0 orders below 0.0 (min(0.0, -0.0) is -0.0) — and abs(x) clears the sign bit (abs(-0.0) is 0.0, abs(nan) is NaN). They lower to llvm.minimum / llvm.maximum / llvm.fabs, inline on every target (f64.min / f64.max / f64.abs on wasm32), so none needs a libm symbol or host import.

Float text

Section titled “Float text”

A Float’s text (to_string(x), println(x), f"{x}", and what the api codec writes) is the shortest that reads back as the identical double, so parse_float(to_string(x)) == x for every finite x, a subnormal included: 0.1 + 0.2 is 0.30000000000000004, 99.999995 is 99.999995, 1.0 / 3.0 is 0.3333333333333333. Of two shortest texts equally near the double, it is the one ending in the even digit. The digits are laid out as C’s %.17g lays them: fixed point when the first digit’s decimal exponent is from -4 to 16, so an integral value has no point (100.0 is 100, 1234567.0 is 1234567), and otherwise one digit, the rest after a point, and a signed exponent of at least two digits (1e+17, 1e-05, 2.5e-300). Negative zero is -0, and NaN and the infinities are nan, inf and -inf. The text is the runtime’s own (lotus_fmt_float_shortest), not the C library’s, so a native and a wasm32 build print the same bytes. A format spec (f"{x:.2}") still rounds to its places.

Reading a decimal back (parse_float, and every Float a codec reads) is the runtime’s own exact reader too (lotus_read_decimal_exact): the nearest double to the decimal written, ties to the even one, from any number of digits, the same bits on every target. A text past the largest double (1e400), or a nonzero one that rounds to zero (1e-400), is refused; a subnormal (5e-324) reads as itself. A text that is no plain decimal (inf, nan) is read as before.

Decimal — the scale is part of the type

Section titled “Decimal — the scale is part of the type”

A Decimal<S> is a fixed-point number: an i128 mantissa m read as m × 10^-S. S, the scale, is an integer literal from 0 to 18 written in the type (Decimal<18>, Decimal<2>, Decimal<0>), and two scales are two types: they never unify, and nothing converts between them implicitly. Plain Decimal is Decimal<9>, the same type under either spelling, with the behaviour and the layout Decimal always had. Decimal<19> (or a scale that is not an integer literal) is a parse error at the scale: an i128 mantissa at scale 18 still holds twenty integer digits (about ±1.7 × 10²⁰), and 10^S is an Int, which the conversions multiply and divide by.

Layout. Every scale is the one i128 (16 bytes, align 16) in a struct field, a locus param, a bus payload and a return; the scale lives only in the type, so changing a field’s scale changes no offset. Decimal is not FFI-portable at any scale.

Literals. A Decimal literal (1.5d) has no scale of its own: it takes the scale of the place it flows into — a let ascription, a parameter, a struct field, a locus param or const ascription, a return or a fn body’s tail, the other operand of an arithmetic or comparison operator, the other argument of min / max, an array literal’s element type, a match’s scrutinee — and is Decimal<9> where nothing gives it one (let a = 1.5d;). So does an expression built only of such values: a negated literal, an arithmetic operator over two of them, a block, an if or a match whose every value is one (let y: Decimal<2> = match n { 1 -> 1.25d, _ -> 0.5d, };), an or over a std::str::parse_decimal / range_parse_decimal call whose fallback is one. An array, a tuple or a [v; N] literal holding a Decimal flows into its place element by element, its shape (length, arity) held first: a scale-less element takes the element’s scale whatever its neighbours are, and any other element is held to the element type ([a, 2.34d] into [Decimal<2>; 2], a a Decimal<2>, is two Decimal<2>s; [1.0d] is not a [Decimal; 2]). So does a bounded push, and a generic struct literal’s field of a parameter bound to a Decimal. An if or a match in expression position joins its arms as an operator joins its operands: a scale-less arm takes the scale the other arms have, and arms of two scales are mismatched. The literal must fit that scale: a nonzero digit past the scale’s last place, or a mantissa no i128 holds at it, is a check error at the literal (“Decimal literal 1.505d cannot be represented: a Decimal<2> has 2 fractional digits, and this one has a nonzero digit past them (it would be truncated); round it to 2 places, or give the place it flows into a wider scale”). Zeros past the last place are the same value and are accepted (1.500d is a Decimal<2>).

Arithmetic is within one scale. +, - and % are exact mantissa operations; * is (a × b) / 10^S and / is (a × 10^S) / b, each an integer division that drops the digits past the Sth place toward zero (1.0d / 3.0d is 0.333333333 at scale 9 and 0.333333333333333333 at 18; -1.0d / 3.0d is the negation; a product below one unit of the scale is 0), with no rounding and no diagnostic. The intermediate is the i128 itself up to scale 9, as Decimal always was, and wraps like Int arithmetic past it; above scale 9 the product and the scaled dividend are i256, so any two operands whose result an i128 holds compute exactly (an i128 intermediate at scale 18 overflows for operands as small as 14), and only a result past i128 wraps. Comparison orders the mantissas. Unary -, abs, min and max keep the scale. An operator, a binding, an argument or a return whose two Decimals have different scales is refused, naming both: “binary op: Decimal<18> and Decimal are different scales: a Decimal’s scale is part of its type, and two scales never mix; convert one explicitly (.rescale(18))”, “Decimal<18> is not Decimal: …”.

d.rescale(T) is the one conversion between scales, T an integer literal from 0 to 18, typed Decimal<T>:

Printing. to_string, println and + with a String render the value at its scale with trailing zeros trimmed (12.50d prints 12.5 at every scale; 0.000000000000000001 at 18). The fixed-places surface is std::decimal::format(d, places) and an f-string precision ({d:.2}): exactly places fraction digits, rounded half-up away from zero, places clamped to 0..=S (there is no digit past the scale to print).

Parsing. std::str::parse_decimal(s) and range_parse_decimal(s, start, end) read at the scale of the place their result flows into (scale 9 where nothing gives one): let p: Decimal<18> = std::str::parse_decimal(s) or raise;. The spelling is the literal’s (an optional sign, _ separators, an optional d), and since 2026-11-07 an exponent as well (1e-7, 1.50E+1, 12.5e1), applied exactly: 1e-7 at scale 8 is 0.0000001. Text with a nonzero digit past that scale, the exponent applied (1e-9 at scale 8), is the call’s ParseError, never a truncation; zeros past it are accepted. So is text whose mantissa at that scale no i128 holds (12345678901234567890123456789012.5 at scale 8, or forty integer digits at any scale): a refusal, never a wrong number (2026-11-07, downstream handoff: the overflow guard relied on signed overflow wrapping, which C leaves undefined, and the compiler dropped it, so such text read as a negative value).

On the wire. A bus payload carries the mantissa (16 bytes) and the scale is the topic’s type, so a field round-trips every digit its scale holds; a payload’s contract shape tags a Decimal<S> field d<S> for S other than 9 (d18; plain Decimal keeps d, spec/model.md § The shape of a type), so a publisher and a subscriber that disagree on a scale disagree on the contract. The JSON codec (T::to_json / T::from_json, the json: tag in spec/semantics.md) writes a Decimal<S> field as a JSON number with its exact digits and reads it back at the field’s scale, from a JSON number or from a JSON string holding one ("97000.50", 2026-11-14), the text held to the JSON number grammar and parsed exactly, never through a float; a nonzero digit past the scale is the field’s wrong_type, as parse_decimal refuses it, never a truncation. A field tagged json:"price,string" is written as a JSON string of the same digits. An api surface’s codecs carry one the same way (spec/api.md § Codecs): JSON as a number at its scale (a string with the tag), its schema {"type": "number", "x-hale-type": "Decimal<S>"} ("string" with the tag), protobuf as its digits in a string.

Units. A quantity, an identity and a range count an integer, an Int or a U64 (spec/units.md § The base), so quantity Decimal<18> in wei is refused as quantity Decimal in wei is (“a quantity counts an integer (`Int`, `U64`), and `Decimal<18>` is not one”).

Generics. Decimal<S> is a generic argument like any primitive: Box<Decimal<18>> is the monomorph Box_Decimal18 (plain Decimal keeps the token Decimal), and a literal in a field of a type parameter bound to Decimal<S> (let b: Box<Decimal<18>> = Box { value: 0.5d };) takes S.

U256 is an unsigned 256-bit integer, 0 through 2^256 - 1; I256 is a signed one in two’s complement, -2^255 through 2^255 - 1 (GH #1934; downstream handoff: chain APIs carry 256-bit balances, token amounts, ABI words and fixed-point AMM prices, past Decimal’s i128). Each is a primitive, lowered to an LLVM i256: 32 bytes at the target’s i256 alignment (16 on x86-64 and aarch64, the arena’s alignment, so a record, a locus, a bounded slot or a fixed array holds one aligned), read and written at align 1 in an enum’s payload (which follows the tag at offset 4) and copied byte for byte on the bus wire.

No literal. A 256-bit integer has no literal of its own (a suffix would collide with a unit’s name, 5u256); U256::f and I256::f in expression position name the functions of std::u256 and std::i256 (spec/stdlib.md), which make and take one:

Call Type What
U256::from_int(n), I256::from_int(n) U256 / I256 an Int, exactly; a negative n made a U256 is a violation
U256::max(), I256::min(), I256::max() the ends of the range
U256::parse(s) or ..., I256::parse(s) or ... fallible(ParseError) decimal digits, or 0x / 0X and hex digits of either case; an I256’s with an optional leading -, its hex the magnitude (never a two’s complement). No +, space, _, empty digits, or a value outside the range: ParseError { kind: "u256" / "i256", input: s }. Leading zeros are accepted (a 32-byte word’s 0x000…01)
U256::from_be_bytes(b) or ..., I256::from_be_bytes(b) or ... fallible(ParseError) exactly 32 big-endian bytes (an I256’s two’s complement); any other length is ParseError { kind: "u256_bytes" / "i256_bytes", input: <b in hex> }
to_string(x), println, f"{x}", + with a String String decimal digits, - before a negative I256
U256::to_hex(x), I256::to_hex(x) String 0x and the lowercase hex digits, none leading (0x0 for zero); a negative I256 is -0x and its magnitude’s
U256::to_be_bytes(x), I256::to_be_bytes(x) Bytes 32 big-endian bytes, an I256’s two’s complement
U256::to_int(x) or ..., I256::to_int(x) or ... fallible(ArithError) the Int, when it fits
I256::from_u256(x) or ..., U256::from_i256(x) or ... fallible(ArithError) the other width, when it fits
U256::checked_add / checked_sub / checked_mul / checked_div(a, b) or ... (and I256::) fallible(ArithError) the operator, failing where it would stop the process
U256::mul_div(a, b, c) or ..., I256::mul_div(a, b, c) or ... fallible(ArithError) a * b / c with the product exact in 512 bits and the quotient rounded as / rounds (down for a U256, toward zero for an I256); c zero, or a quotient outside the range, fails

ArithError { kind, op } is a builtin type in every program: kind is overflow or division_by_zero, op the call (U256::checked_add).

Arithmetic never wraps. Int arithmetic wraps on overflow (two’s complement, as Decimal’s i128 does past its range), but a 256-bit integer holds money-like quantities, where a wrapped value is a wrong balance, so +, -, *, /, % and unary - stop instead: a result outside the range, a division or remainder by zero, I256::min() / -1 and -I256::min() are each a runtime violation where they happen, the process printing what happened (violation: U256 + overflows: the result is outside U256's range, 0 through 2^256 - 1 (U256::checked_add fails instead of stopping)) and exiting 1, the shape of Time’s range violation. I256::min() % -1 is 0, which fits. The checked_* calls and mul_div are the forms that fail into an or instead. Division and remainder round as Int’s do: / toward zero, and % takes the dividend’s sign (I256 -7 / 2 is -3, -7 % 2 is -1). The comparisons order the values (unsigned for U256, signed for I256); min, max and abs take them (abs(I256::min()) is a violation).

Bits. &, |, ^ and ~ are bitwise. x << n and x >> n shift by an Int count n and are bit operations, not arithmetic: bits shifted past either end are dropped (* is the checked multiply), a count of 256 or more shifts every bit out, and an I256’s >> fills with its sign, so x >> n is floor(x / 2^n) (an Int’s >> is logical). A negative count is a violation.

No implicit mixing. A U256 and an I256 mix with nothing else: an operator over a 256-bit integer and an Int (or a Decimal, a Float, the other 256-bit type) is refused naming the conversion (“binary op: U256 and Int do not mix: a 256-bit integer never converts implicitly; make the Int a U256 with U256::from_int(n)”), and so is a binding, an argument or a return of the wrong one (“let c: expected U256, got Int: a 256-bit integer never converts implicitly; write U256::from_int(n)”). A U256 has no unary -.

Where it goes. A record or locus field, a bounded[U256; N] buffer, a fixed array (inline, as a Decimal’s), an enum’s payload, a hashmap cell’s field, a generic argument (Box<U256>), a bus payload (its 32 bytes; a topic’s contract shape tags it u256 / i256, spec/model.md § The shape of a type), the JSON and protobuf codecs (spec/api.md § Codecs: a JSON string of its digits, decimal or 0x hex). It is no Numeric generic bound’s argument, no routing key and no @ffi parameter.

U64 is an unsigned 64-bit integer, 0 through 2^64 - 1 (18446744073709551615; GH #2121): a hash, a counter or a sequence number that runs past 2^63, an identifier or a protocol field a foreign system hands out as a uint64. It is a primitive lowered to an LLVM i64 read as unsigned: the same 8 bytes, at the same alignment, as an Int in a record, a locus, a bounded slot, a fixed array (inline), an enum’s payload and the bus wire. It replaces the reserved Uint, which the parser read and the checker refused.

Literals take the type of their place. An integer literal whose place is a U64 is one: a let ascription, an argument, a return or a fn body’s tail, a record or locus field (and its default), an assignment, the other operand of an arithmetic, bit or comparison operator, the other argument of min / max, an array literal’s element type (and [v; N]), a bounded push, a block, an if or a match whose values are such literals beside a U64, an or’s fallback, and a match pattern against a U64. So is an operator over such literals (let top: U64 = 1 << 63;, the shift’s count an Int; let mask: U64 = ~0;). The checker records the literal’s type, and lowering lays it out from that record. A decimal literal past Int’s max, 2^63 through 2^64 - 1, is a U64 by itself (let m = 18446744073709551615;), and anywhere a U64 is not expected it is a check error at the literal:

type error: integer literal 9223372036854775808 is past `Int`'s max (9223372036854775807): only a `U64` holds it, and its place is `Int`: give the place the type `U64`

A literal past 2^64 - 1 is a lex error at the literal. A radix literal (0xFFFF_FFFF_FFFF_FFFF) is its 64-bit pattern, as it is for an Int. A U64 is never negative: -5 (any -) where a U64 is expected is a check error at it, never a wrapped value (“`-5` cannot be a `U64`: a `U64` is 0 through 2^64 - 1 (18446744073709551615) and has no unary `-`; write the value itself, or keep it an `Int`”).

Functions. U64::f in expression position names the function f of std::u64 (spec/stdlib.md):

Call Type What
U64::from_int(n) U64 an Int, exactly; a negative n is a violation
U64::max() U64 2^64 - 1
U64::to_int(x) or ... fallible(ArithError) the Int, when x is at most 2^63 - 1
U64::from_bits(n), U64::to_bits(x) U64 / Int the same 64 bits read as the other type (-1 is U64::max()): never fails
Float(x) Float the nearest double (uitofp): exact through 2^53
U64::from_float(f) or ... fallible(ArithError) f truncated toward zero, when that is in range; NaN, an infinity, -1.0 or less and 2^64 or more fail
U64::parse(s) or ... fallible(ParseError) decimal digits, or 0x / 0X and hex digits of either case; leading zeros are accepted. A sign, a space, _, no digits or a value past 2^64 - 1 is ParseError { kind: "u64", input: s }
U64::from_be_bytes(b) or ..., U64::from_le_bytes(b) or ... fallible(ParseError) exactly 8 bytes, big- or little-endian; any other length is ParseError { kind: "u64_bytes", input: <b in hex> }
U64::to_be_bytes(x), U64::to_le_bytes(x) Bytes its 8 bytes
to_string(x), println, f"{x}", + with a String, a @display hole String decimal digits, unsigned
U64::to_hex(x) String 0x and the lowercase hex digits, none leading (0x0 for zero)
U64::checked_add / checked_sub / checked_mul / checked_div(a, b) or ... fallible(ArithError) the operator, failing where it would stop the process
U64::wrapping_add / wrapping_sub / wrapping_mul(a, b) U64 the operator modulo 2^64, for hashes and bit work
U64::wrapping_shl / wrapping_shr(x, n) U64 the shift by n modulo 64 (n an Int)

Arithmetic never wraps unless asked. Int arithmetic wraps (two’s complement); a U64’s follows F.46’s rule for the 256-bit integers instead: +, - and * past either end, and / or % by zero, are a runtime violation where they happen, the process printing what happened and exiting 1 (violation: U64 \+` overflows: the result is outside U64’s range, 0 through 2^64 - 1 (U64::checked_add fails instead, and U64::wrapping_add wraps)). Overflow is detected with llvm.uadd/usub/umul.with.overflow. U64::wrapping_wrap andU64::checked_fail into anor (ArithError { kind, op }, kind overflowordivision_by_zero, opthe call)./and% are unsigned (udiv, urem), the comparisons order unsigned (icmp u*), minandmaxtake twoU64s (or one and a literal), and abs(x)isx. A U64has no unary-`.

Bits. &, |, ^ and ~ are bitwise. x << n and x >> n shift by an Int count n; >> fills with zeros (lshr). A count outside 0 through 63 is a violation (violation: U64 shift by a count outside 0 through 63), where a U256’s count of 256 or more shifts every bit out: a 64-bit shift by 64 or more is undefined in C and a panic in Rust, and answering it with zero would hide the bug the count is. The wrapping_shl / wrapping_shr calls take the count modulo 64, as a hash wants.

No implicit mixing. A U64 mixes with nothing else: an operator over a U64 and a non-literal Int (or a Float, a Decimal, a 256-bit integer) is refused naming the conversion (“binary op: `U64` and `Int` do not mix: a `U64` never converts implicitly; make the `Int` a `U64` with `U64::from_int(n)`, or the `U64` an `Int` with `U64::to_int(x) or …`”), and so is a binding, an argument or a return of the wrong one (“let `c`: expected `U64`, got `Int`: a `U64` never converts implicitly; write `U64::from_int(n)`”). Int(x) of a U64 is refused for U64::to_int(x) or ..., which can fail.

Where it goes. A record or locus field, a bounded[U64; N] buffer, a fixed array (inline), an enum’s payload, a hashmap cell’s field, a generic argument (Box<U64>), a fn’s parameter and return, a bus payload (its 8 bytes; a topic’s contract shape tags it u64, never an Int’s i, spec/model.md § The shape of a type), an @ffi("c") parameter or return (a C uint64_t; at @ffi("js") the JS number of its unsigned value, uitofp / fptoui, exact through 2^53 as an Int’s is; spec/ffi.md), and the JSON and protobuf codecs (spec/api.md § Codecs):

It is no routing key, no Numeric generic bound’s argument and no accumulator’s element (sum(self.x)).

Units over U64 (GH #2131, F.62). The unit dialect’s base integer is a parameter (spec/units.md § The base), and a U64 is one: type Wei = quantity U64 in wei;, type Nonce = distinct U64; and type Port = U64 { range: 1..65536; } are each a U64 that never mixes. Each one’s arithmetic, range checks and conversion factors are a U64’s: unsigned, an overflow a violation; a literal where one is expected is typed from its place as above; U64(nonce) is an identity’s U64 and Nonce(n) of a U64 the identity; and an Int beside one is refused naming the conversion, as beside a U64. A component counts one integer, so an Int count and a U64 count of one denomination never mix (spec/units.md law 5): the stdlib’s Duration counts an Int, and a U64 count of time is a quantity of a unit of its own. On the wire, in a shape and across @ffi("c") each is the U64 it counts (q(u64 wei), u64, a JSON string of its digits, a uint64, a uint64_t).

Postgres has no unsigned integer column: bigint stops at 2^63 - 1. A U64 is stored in a numeric(20) column (twenty digits hold 2^64 - 1 exactly), passed and read as its decimal text (to_string(x) in, U64::parse(s) or ... out), as a text-format driver such as pond’s pq binds every parameter. Hale has no column mapping of its own to refuse a bigint at.

Fixed-width integers — I32, U32, I16, U16, I8, U8

Section titled “Fixed-width integers — I32, U32, I16, U16, I8, U8”

I32, U32, I16, U16, I8 and U8 (GH #2132, F.64) are the integers of a declared width: signed two’s complement (I) or unsigned (U), 32, 16 or 8 bits. I32 holds -2147483648 through 2147483647, U32 0 through 4294967295, I16 -32768 through 32767, U16 0 through 65535, I8 -128 through 127 and U8 0 through 255. Each is an LLVM i32, i16 or i8, and each is its declared width wherever it is stored: a record field, a bounded[T; N] element (a bounded[U8; 1024] field is its count and 1024 bytes), a fixed array (inline), a locus field, a topic payload’s field and a local, so a loop over them works lanes of that width. An enum’s payload keeps its eight-byte slot. There are no aliases: a byte is U8, and type Byte = Int { range: 0..256; } stays the range type it is.

Literals take the type of their place, as a U64’s do (every place listed under § U64), and are held to its range where they are written: let b: U8 = 256; is a check error at the literal (“integer literal 256 does not fit `U8`, which is 0 through 255: …”), and so is a negative literal where an unsigned one is expected (“`-1` cannot be a `U8`: … has no unary `-`”). A negated literal is held as the value it is: -128 is an I8, though 128 is not. A radix literal is its value (let m: U8 = 0xFF;). A literal cast U8(200) is the literal.

Functions. T::f in expression position names the function f of std::i32 … std::u8 (spec/stdlib.md):

Call Type What
T::max(), T::min() T the ends of the range
T::checked_add / checked_sub / checked_mul / checked_div(a, b) or ... fallible(ArithError) the operator, failing where it would stop the process (kind overflow or division_by_zero, op the call)
T::wrapping_add / wrapping_sub / wrapping_mul(a, b) T the operator modulo 2^width: a hash, a checksum, a vectorizable kernel
T::wrapping_shl / wrapping_shr(x, n) T the shift by n modulo the width (n an Int)
Int(x), Float(x) Int / Float exact
to_string(x), println, f"{x}", + with a String, a @display hole String decimal digits; {x:x} the hex of its own width’s bits (-5 as an I8 is fb)

Arithmetic never wraps unless asked, as a U64’s (F.60): +, - and * past either end, / or % by zero, a signed / of the minimum by -1 and a signed unary - of the minimum are a runtime violation where they happen, the process printing what happened and exiting 1 (violation: U8 \+` overflows: the result is outside U8’s range, 0 through 255 (U8::checked_add fails instead, and U8::wrapping_add wraps)). Overflow is detected with llvm.{s,u}{add,sub,mul}.with.overflowat the width. A signed one's/truncates toward zero and its%takes the dividend's sign (the minimum's remainder by-1is0); an unsigned one's are udiv/urem, and its comparisons and min/maxorder unsigned.abs(x)of an unsigned one isx; of a signed one it is checked. An unsigned one has no unary -`.

Bits. &, |, ^ and ~ are bitwise at the width. x << n and x >> n shift by an Int count; >> is arithmetic on a signed one (it fills with the sign bit, as I256’s does) and logical on an unsigned one. A count outside 0 through the width less one is a violation (violation: U8 shift by a count outside 0 through 7); the wrapping_shl / wrapping_shr calls take the count modulo the width.

Conversions.

The element chain’s sum. .sum(seed) accumulates in its seed’s type (sum(0.0) for a Float), so a sum of a fixed-width integer names one: .map(it * 3).sum(U32(0)). Its + is checked like every other, so the loop carries an overflow branch per element and is not vectorized; a kernel that wants lanes says U32::wrapping_add / wrapping_mul, which are plain adds and multiplies at the width (on aarch64 four i32 lanes a NEON instruction, where an Int’s .map(it * 3) has no vector multiply). @vectorize(min_width: 4) holds for such a U32 fold on aarch64 and x86-64, and refuses the checked one at its loop (spec/semantics.md § Vectorized loops).

Where it goes. Everywhere a U64 goes (§ U64), at its own width: a record or locus field, a bounded buffer, a fixed array, an enum’s payload, a hashmap cell’s field, a @form(vec) slot, a generic argument (Box<U8>), a fn’s parameter and return, a bus payload (its width on the wire; a topic’s contract shape tags it i32, u32, i16, u16, i8 or u8, spec/model.md § The shape of a type), an @ffi("c") parameter or return (the C int32_t … uint8_t, an 8- or 16-bit one extended to the register as its signedness says; at @ffi("js") a JS number; spec/ffi.md), and the JSON and protobuf codecs (spec/api.md § Codecs):

It is no routing key, no hashmap key, no Numeric generic bound’s argument and no accumulator’s element (sum(self.x)), as a U64 is not.

Units. A fixed-width integer is a base of the unit dialect (spec/units.md § The base): type Ticks = quantity U32 in tick;, type Level = U8 { range: 0..100; } and type Port = distinct U16; count one, with its arithmetic (unsigned or signed, an overflow a violation), its conversions and its four, two or one bytes of storage. A component counts one integer, so a U32 count of time is a quantity of a unit of its own (the stdlib’s Duration counts an Int).

Beside the primitives, a program declares the unit dialect’s scalar types. spec/units.md is their whole contract (the declarations, the laws, the algebra, the conversions and their policies, printing and the wire); what the type system holds of them is this. Each is a nominal named type, not a new primitive: the name survives resolution, two of them never unify, and each is represented as the integer it counts, an Int or a U64 (spec/units.md § The base).

Kind Declared As a type
Identity type OrderId = distinct Int; (distinct U64), optionally { range: a..b; } no arithmetic; compares within one; widens to nothing (Int(id), OrderId(n) convert)
Range type Byte = Int { range: 0..256; } (U64 { range: … }), or over an identity or a range widens to its parent for free; narrowing into it is Byte(n) or …
Quantity type Money = quantity Int in cent; (quantity U64 in wei), or a boundary denomination of one, type Ledger = quantity Int in cent { round: half_even; } carries its denomination; converts by an exact factor
Point type Price = point Tick;, optionally { origin: N UNIT; } a position over its quantity

An expression’s quantity or point type carries its denomination, and one no declaration names is a synthesized type, keyed by its quantity and its denomination as a monomorph is by its arguments, and displayed Money in 1/10000 cent (spec/units.md § Synthesized denominations). Duration and Time are a quantity and a point declared by the stdlib, which keep their own representation class (the table above).

Construct Form Notes
Array [T; N] Fixed-size: N is an integer literal, 0 included ([x; 0], a [T; 0] parameter). An unsized [T], or a length spelled by a name ([T; N] with N a const), is refused by hale check at the annotation (see § “What the compiler cannot compile yet”).
Bounded collection bounded[T; N] Fixed-capacity counted list, INLINE in its containing type/params ({ i64 len, [N x T] }). See § “bounded[T; N]” below.
Tuple (A, B, C) Fixed-size heterogeneous
Struct type Foo { x: Int; y: Int = 0; } Named record, a value: let b = a; copies (see § “A struct binding is a copy”). Each field can declare a default value (= expr); literals omitting a defaulted field fill it from the default at instantiation time, the default evaluated where the literal that leaves it is written. A default reads only its constants and the module’s items, never the literal’s scope (§ Locus params).
Enum type Foo = enum { A, B(int) }; Tagged union (sum type). A constructor call carries the variant’s declared values: Foo::B(x) is checked for the count and each value’s type, a Decimal literal taking the field’s scale (“`Foo::B` value 0: expected `Int`, got `String`”). A path to a variant the enum does not declare is a type error at the path, wherever it is written (a value, an operand, a constructor call, a match pattern), naming the nearest variant (“enum `Place` has no variant `Wrok` — did you mean `Work`?”) or listing them, and through an alias too (a concrete alias of a generic enum, `type I = E;`, is named as its instantiation, `E`); until 2026-11-17 the check passed it and the build refused it. A pattern may name a variant with a leading dot against a value of the enum, .B(x) for Foo::B(x) (F.58, spec/semantics.md § `.Variant` patterns). A payload-free enum is stored as its tag.
Set type Inbound = Book | Trade; Untagged union: each member is a declared struct or enum and is its own discriminant. A member’s value is the set’s where a set is expected; match names a member by its type. See § “Set types”.
Alias type Thing = Int; A second SPELLING of a type, not a new type. See § “Type aliases”.
Function fn(A, B) -> C First-class function values
Generic Foo<T> Parametric over type T

A variant may declare an error class before its name, @not_found Missing, one of @not_found, @conflict, @invalid, @forbidden and @unavailable; it is what a served member’s handler error of that variant is answered with (spec/api.md § Error classes), and any other word is a type error.

A variant has one external name: its json: tag’s key when it has one (Sell `json:"sell"` , spec/api.md § Codecs), else the spelling its enum’s @wire_case(...) gives it, else its declared name. The JSON codecs read and write it, and so do four functions the compiler writes for every enum E:

Spelling Type What it is
E::name(v) String v’s external name. Payloads are ignored (Shape::name(Shape::Circle(2.0)) is "Circle"); a lossless catch-all (Other(String) `json:",other"` ) names the string it holds.
E::parse(s) E fallible(ParseError) The variant s names, compared exactly against each external name; any other string fails with ParseError { kind: "unknown_variant", input: s }. With a catch-all it is plain E, never failing: an unknown name is the catch-all, holding the string when it is lossless, as the JSON codec reads one.
E::variants [E; N] A value, not a call: every variant in declaration order, the lossless catch-all left out (it needs a string).
E::index(v) Int v’s declaration ordinal, from 0, payloads ignored.
type Lifecycle = enum { Active, Archived };
fn status(row: String) -> Lifecycle {
return Lifecycle::parse(row) or Lifecycle::Active;
}
fn main() {
for l in Lifecycle::variants {
println(Lifecycle::index(l), " ", Lifecycle::name(l));
}
}

parse and variants apply to an enum whose variants carry no values, with at most one lossless catch-all; on any other enum the call is refused, naming the variant that carries values (“`Shape::parse` builds a variant from its name alone, so it applies to an enum whose variants carry no values (…), and `Shape::Circle` carries 1 value; match on the name and build the variant yourself”). None of the four is written for a generic enum yet, and each is refused there with that reason. E::variants() is refused (“`E::variants` is a value, … not a function: write `E::variants`, without the parentheses”), as is E::name, E::parse or E::index used as a value or called with other than one argument. An imported enum’s are spelled through its alias, lib::E::name(v), and an alias of an enum names the enum’s.

The four names are contextual, as framework vocabulary is (F.43): an enum that declares a variant named name, parse, variants or index keeps meaning its variant (Field::name is the variant name), and the other three are still the enum’s.

to_string, println and an f-string keep rendering a variant as Enum::Variant (Lifecycle::Archived); the external name is what crosses a wire, a store or a log line that asks for it. A variant’s human text is a different thing, declared with @display (next section): the external name is the wire’s, the template is the reader’s, and neither reads the other.

@wire_case(case) on an enum’s declaration spells every variant in one case: snake (InProgress is in_progress, HTTPError is http_error), screaming_snake (IN_PROGRESS), kebab (in-progress) or lower (inprogress, the name in lower case). Words break at _, at a lower-case letter or digit followed by a capital, and before the last capital of a run that a lower-case letter follows; a digit stays with its word (Http2Error is http2_error). A variant’s own json: key still wins, and a lossless catch-all keeps none (it writes the string it holds). It is an annotation, not a keyword: it marks an enum and stacks with nothing, and on a record, a set or with any other case it is a parse error. Two variants whose spellings meet (FooBar and Foo_Bar under snake) are refused as two variants of one wire name are.

@wire_case(snake) type Phase = enum { InProgress, HTTPError, Done `json:"finished"` };
// Phase::name(Phase::InProgress) is "in_progress", Phase::name(Phase::Done) "finished"

A record, and an enum’s variant, may declare how its values render as text for people with @display("…"): literal text and holes naming its fields ({dollars}, {cents:0>2}), or a variant’s payload positions ({0}). Every rendering path reads it, {x:?} bypasses it at every depth, and T::display(v) names it. A template never widens the printable set: it is allowed only on a record that is already printable. It is not allowed on a generic type, an enum as a whole, a set, an alias, a scalar or a locus. The rules are in spec/semantics.md § Rendering values as text.

@display("${dollars}.{cents:0>2} {currency}")
type Money { dollars: Int; cents: Int; currency: String; }
type Side = enum { @display("buy") Buy, @display("sell") Sell, Other(String) };
// to_string(Money { dollars: 12, cents: 5, currency: "USD" }) is "$12.05 USD";
// f"{m:?}" is "Money { dollars: 12, cents: 5, currency: \"USD\" }"

A struct declares each field once, and an enum declares each variant once. A second declaration of a name already declared in the same type is a type error at the second, naming the first:

main.hl:4:5: type error: field `a` is already declared in type `T`;
a name is one slot, so declare it once
main.hl:2:5: the first declaration

The same rule holds for a locus’s params, for the named members of a contract, and for an interface’s methods. Before it, the second declaration passed hale check and one of the two won the slot, with nothing in the source to say which — while the json codecs and a surface’s description assume one slot per name.

Optionality is a property of a record field, not a type. x?: T in a type declares the field x and, right after it, a real field has_x: Bool = false, its presence flag; x?: T clearable declares a third, clear_x: Bool = false, after that:

type Ticker {
symbol: String;
last?: Decimal<8>;
raw?: std::json::Value;
expires_at?: Time clearable;
limit?: Int = 100;
}

The flags are ordinary fields in every way: read and written by name, held in the record’s own slots, declared exactly as the hand-written presence pair (x then has_x) and triple (x, has_x, clear_x) the api codecs read (spec/api.md § Codecs). So the JSON and protobuf codecs, the bus wire, a surface’s description and its contract digest see one shape, and converting a hand-written pair to the mark changes no shape hash. A record that declares has_x itself beside x? (or clear_x beside a clearable x?) is refused at that declaration: the mark declares it already (§ One name, one field).

What the mark adds is how the flags follow the field:

A hand-written pair keeps working as it always did: its has_x is written by hand, and writing x leaves it alone.

Nothing else is optional. ? on a parameter, a locus param or a local is a parse error naming the position, and so is T? after any type (a field’s, a return’s, an enum payload’s): Hale has no optional type, and absence in a computation is fallible(E) (§ Fallible typing). A @positional record’s fields take no ?, since every field of a positional row is an element.

let b = <place>; where the place holds a struct — a field of self or of a child, a local, an element — binds a copy: a fresh struct in the frame’s own region (a method’s scratch; the caller’s arena for a binding the fn hands back), its String and Bytes fields cloned, nested structs copied the same way, locus handles left as handles. The binding then follows nothing: replacing the source (self.row = Row { }) leaves b as it was read, and writing through the binding (let mut c = self.row; c.n = 9;) leaves the source untouched. A literal is fresh already and is bound as it is; so is a call’s result, unless the callee may hand back a place’s value (§ A local bound from a place is yours). A value read from a form’s cell (m.get(k) or d) is the reader’s in the same way: writing into it never changes the cell, though the compiler keeps its nested parts shared with the cell until a write could show (spec/forms.md § Reading a cell). Assignment reads the same way (GH #992): b = <place> on a struct local, and arr[i] = <place> or b.inner = <place> under one, store a copy. And a write through a local never reaches another (GH #993): a copy may share an unchanged String with its source, so a String or Bytes field under a local root is replaced, never overwritten in place — only a locus’s own storage takes the in-place path. This finishes for structs the single-owner rule spec/memory.md states for String and Bytes stores (2026-09-22; before it the binding was a view of the storage, and an acknowledgement body read after the proposal field was cleared came back empty). A deliberate view has no spelling yet; read the field again when the current value is wanted.

A String, Bytes, tuple, array or payload-enum value bound from a place — let s = self.f.s;, let (a, n) = self.pair;, a bare x = self.f.s, a match self.e { E::A(s) -> .. } payload, the array a for x in self.f.names walks — and a place passed straight to a call (self.take(self.f.s)) keep the value they were given, whatever replaces the place while they are live. So does a value carried out of a place by another expression: a match arm’s payload (let held = match self.e { E::A(s) -> s, E::B -> "", };), an if or block result, a tuple, array or record literal holding it, an or substitute, an enum constructor holding it. (A stdlib call’s result is built fresh, and a method’s copied out of its locus into the caller’s arena; a call that may hand back a part of an argument or a form cell’s read is a place’s value, § A local bound from a place is yours.) The compiler keeps these the place’s own pointer where it can, which costs nothing: it binds an owned copy only when a write that may replace the place comes between the binding and a use of it (or is the call it is passed to; an argument is passed by reference, so only a String or Bytes argument is copied — a record, tuple or array handed to a callee stays the caller’s, and what the callee writes through its parameter the caller sees — unless a later argument’s evaluation replaces its place, when it is copied whole: nothing is left to write through). An operand held while a later one is evaluated — an earlier argument of a call, a method’s receiver, a binary operator’s left side, an earlier field of a literal — is copied where it is evaluated when the later one may replace its place (take(match self.e { E::A(s) -> s, E::B -> "", }, self.reset())). Such a write is a store into the place’s field (self.f.s = .., self.f = .., through any root), a call whose callee writes it, transitively (a method of the locus its receiver’s type names, only that locus’s; a method through an interface, any locus’s of the name; a method called on the field itself, as a form’s set), and anything that may run other code of the locus: a publish, yield and a stdlib call that parks on an async_io pool write what the program’s bus handlers write (a publish lowered as a direct call of its one subscriber’s handler writes what that handler writes), and a call the checker did not resolve — through a fn value (a local, a parameter, a field of fn type), of a name no declaration answers to, on a receiver it could not type — and a recovery statement may write anything. Every one of these questions is answered over the types the checker resolved (the ones it checks the program against: an alias, an imported seed’s lib::Kid, a qualified name and a fn-typed alias are what they name, whatever the spelling), never over a spelling resolved again; where the checker has no type for a value or no callee for a call, the binding is an owned copy. A field of a record the frame holds itself is never replaced under a binding of it (a write through a local root replaces the field’s pointer); a field read through a handle is — a value whose type is a locus or an interface, however it is spelled (an alias, an imported seed’s lib::Kid, a binding’s declared type). A write inside a loop reaches a use anywhere in the loop when the variable was declared before the loop — a local declared outside and rebound inside (held = self.f.s; then a replacing call, read on the next iteration) included. Before this a String local held across a method that replaced its field read the block the replace retired, reused by the next allocation (spec/memory.md rules 6 and 7), and a same-length store into the field changed the local in place.

Writing into a local bound from a place never changes the place, and writing into the place never changes the local (ruling of 2026-10-13). The local is any binding: a let or let mut, a bare =, a tuple let’s element, a match payload, a for element of an array, and a part of a local assigned from a place (h.arr = r.arr;, xs[0] = m.get(k) or d;); the place is a field (of self, a child, a record local, a parameter), an element, a local, a parameter, or a value carried out of one (a match or if result, a literal holding it, the result of a call that may hand it back). A call may hand back a place’s value when its callee returns a part of a parameter (fn get_in(r: R) -> In { return r.arr[0]; } returns the caller’s block uncopied), a form cell’s read (fn read() -> Rec { return self.m.get(1) or Rec { }; }), or what a callee that does returns — transitively, by which parameter. A callee the compiler cannot identify (a call through a fn value, a name nothing declares) may hand back a part of any argument its declared result type can be, hold or share a record, enum, array or tuple with (a Response handed back by fn(Context) -> Response is no part of the Context), and anything where that type is unknown; through a fn value that may be a method read as a value, also whatever that method’s receiver holds. A result declared a primitive or a handle never is one; a result fresh at its top level that holds such a value in a field (a returned struct literal around r.arr[0]) copies only when a write goes below that field. A free fn returning a field read through a handle parameter (fn arr_of(k: K) -> [In; 2] { return k.r.arr; }) hands back that locus’s storage, a place’s value; a locus’s method returning its own fields hands back a copy. A place’s value assigned into a part of a parameter (fn store(h: Holder, r: R) { h.arr = r.arr; }) is stored as a copy, so the caller’s two arguments never share a block. A cell’s read handed back through a call keeps its kind: passed straight to a callee that writes through it, it is copied where it is evaluated. A write into it is an assignment at any depth (a[0] = x, x.k = 1, b[i].inner.s = s), a push, set, clear or truncate of a bounded list in it at any depth (push(t.notes, n), push(t.meta.notes, n), as t.notes = … is), or a call that may write through its parameter. Until GH #2099 an intrinsic on a list below the local wrote in place, so let mut t = at(r.tags, 0) or …; push(t.notes, n) changed r’s element.

let mut a = self.r.names;
a[0] = "x"; // self.r.names is unchanged
match self.r.e { P::A(i) -> { i.k = 1; }, P::B -> { }, } // so is the payload
for x in self.r.cells { x.k = 1; } // and every element
let held = r.names;
r.names[0] = "y"; // held[0] is what it was

How the compiler keeps this is its business, and it keeps reads free: the binding stays the place’s own block until a write into it, which copies the whole value into the frame first (copy on write, a flag per local set at each binding, so one copy serves every later write; a for element is copied at its first write in each iteration). A struct let or = of a place is a copy already (§ A struct binding is a copy); a struct literal holding a place’s value copies only the field written below (let mut l = R { a: self.a }; l.a[0] = x; copies a). A local handed to a call that may write through its parameter is bound as a copy, and so is a binding live across a write into the local’s or parameter’s value it was read from. Four shapes are not copies:

Each copy is a site of the allocation survey (place-copy (<reason>): copy: written local bound from a place, copy: a local bound from a place is passed to a call that may write through its parameter, copy: what the local was read from is written while it is live), so it counts toward @budget(alloc_per_call = N) and the alloc effect, and the hot-path lint reports one in a loop or a bus handler (when asked for: hale verify, hale check --warn-hot-path) and in a @hot fn. A store’s own copy is one too: copy: a place's value stored into a part of a parameter (h.arr = r.arr), and copy: a value stored into a locus's field from outside its methods (§ A store into a locus’s field is the locus’s own), unless the slot or the value is an inline scalar. The latter is store-latest, as a method’s self.f = v is: a @hot fn’s error and a budget’s count, never a loop’s or a handler’s warning. A field of self handed to a call that may write through that parameter (poke(self.source)) is written there, as a store into it is, so a local or a literal’s part viewing it is copied first. A call through a parameter declared a fn returning a primitive (cb: fn(Int) -> Int) hands back a primitive, as a declared fn of that signature does. A bounded[T; N] local is held to the same rule (decisions F.49, GH #1951): let mut dest = self.xs; push(dest, s) or …; leaves self.xs as it was, and a write into self.xs while dest is live does not reach dest. A bounded intrinsic that writes the local (push, set, clear, truncate) is a write into it: the local takes its own copy at the first one (its storage and its live pointer-shaped elements, in the frame’s arena) unless the frame owns it already, and the element stored is kept in the frame. A local only read stays the place’s storage, so a for over it or a count of it costs nothing; one bound across an in-place write of its place, or handed to a call that may write through its parameter, is bound as a copy, as any binding of a place is. To write the place, name it (push(self.xs, s)), or store the local back whole (self.xs = dest;). Until F.49 a bounded local was a view: an intrinsic on one bound from a field wrote the field, its element anchored where the field lives. Before this rule the write landed in the place’s block: let mut a = self.r.names; a[0] = x; changed the field.

A set type (GH #1530, 2026-10-17) is an untagged union: type Inbound = Book | Trade | Unknown;. Each member is a struct or an enum the program declares, and the member’s type is the discriminant, so nothing is named twice: no variant names a type that is already a name. A primitive, a list, a tuple or a function type is no member (a parse error: declare a struct that holds the value), nor is an alias of one; a set is no member of a set (name its members instead); a member is named once, and two members may not share the last segment of their names (a::Book and b::Book), since a pattern names a member by that alone.

A member’s value is the set’s wherever a set is expected: a return from a fn returning the set (a return, or the body’s tail, which is its return), an argument to a parameter of it, a let of its type, an assignment to a place of it and a field of it. The error channel of a fallible(S) fn is such a place (GH #1951): fail m;, or fail err, an or raise of a call failing with a member and a fallible handler’s failure with one are the set’s, so with type LoadError = ParseError | IoError; a fallible(LoadError) fn raises either (spec/semantics.md § “Converting a raised error”). Two sets may share a member; the place’s type says which set the value becomes. The arms of an if or a match whose values are different members are not joined into a set: give each arm the set’s type (a fn returning it).

match names each member by its type alone, binding the member’s value at the member’s type (b below is a Book; spec/semantics.md, a pattern’s bindings):

fn handle(m: Inbound) -> Outbound {
return match m {
Book(b) -> answer(b),
Trade(t) -> fill(t),
Unknown(u) -> reject(u.raw),
};
}

A name that is no member of the scrutinee’s set is refused (“Side is not a member of the set Inbound, whose members are Book, Trade, Unknown”), and the match is exhaustive as an enum’s is: every member, or a _ arm. Name(_) matches a member without binding it; a bare Name is a binding, as everywhere.

The bare name is a set’s alone, against a value the check knows to be of the set. A pattern on an enum names its enum, E::A(x), or the variant with a leading dot, .A(x), which means the same against a value of E (F.58; a .A(x) against a set is refused, its members being named by their types alone); A(x) against anything but a set (an enum, a generic fn’s type parameter, a value whose type the check cannot name, a type that is no enum) is refused at the pattern (until 2026-11-15 the check passed it and the build refused it):

main.hl:5:9: type error: `A(…)` names a variant of the enum `E` without
its enum: a pattern on an enum names it, `E::A(…)` (only a set's member
is named by its type alone)

Underneath, a set is an enum whose variants are its members, each named for its type and holding one value of it, and it costs what that enum costs: Inbound::Book(b) is the same value as b flowing into an Inbound, and both spellings are accepted. It prints as that enum does (Inbound::Book(Book { id: 7 })).

type Name = Type; declares an alias: a second spelling of an existing type.

type Thing = Int;
type Row2 = Row;
type Names = Vec<String>;
type Span = (Int, Int);

An alias is transparent, not nominal. It is replaced by its target wherever a type is written, so the alias and its target are the same type — they unify in both directions, share every field, and dispatch to the same methods:

type Thing = Int;
fn bump(t: Thing) -> Thing { return t + 1; }
fn main() {
let t: Thing = 3; // an Int
let u: Int = bump(t); // and back, with no conversion
}

The consequences are all one rule:

Rich<T>, Chunked<T>, Recognition<T> are language-native generic constructors. The compiler recognizes them and selects allocator + implementation strategy based on which projection- class wrapper a value carries (per memory.md).

The constraint <T: ProjectionClass> (per F.2) is a built-in “any-of-three” constraint: T must instantiate to Rich<U>, Chunked<U>, or Recognition<U> for some U. No trait system required.

fn process<P: ProjectionClass, T>(input: P<T>) -> P<U> { ... }

The compiler monomorphizes per concrete P instantiation.

A locus L { ... } declaration introduces a locus type L. Locus types have:

Instantiating a locus type produces a locus handle of that type, allocated as a region within the enclosing scope (per memory.md).

A store into a locus’s field is the locus’s own

Section titled “A store into a locus’s field is the locus’s own”

A store into a locus’s field from outside that locus’s methods is the locus’s own store, exactly as a method of it storing self.f = v (GH #1561). Such a store goes through a handle parameter (fn put(l: L, s: String) { l.name = s; }), a handle local (let l = L { }; l.name = s;), a child reached through a handle or through self (h.loc.name = s, self.loc.name = s in the parent’s method), or an element of an array of loci (ls[i].r.arr = r.arr). The locus that owns the field is the last one on the store’s path: loc in h.loc.name, the element in ls[i].r.arr.

A store below a record held in a locus’s field (l.r.arr = v, l.c.s = s) is the same store, owned by that locus. The parameter-part rule (§ A local bound from a place is yours: h.arr = r.arr copies) is about a record the caller holds, not a locus, and adds no copy to a store through a handle: the store’s copy into the locus is the only one.

A locus body may not declare a type. type X { ... } is a top-level declaration only (see grammar.ebnf: type_decl is a top_decl, not a locus_member), and a type inside a locus body is a type error at the type keyword:

main.hl:2:5: type error: `type Pair` is declared inside locus
`Holder`: `type` is a top-level declaration, not a locus member.
Move it above the locus — a top-level `type` is in scope
everywhere in the seed, including inside every locus.

A top-level type is the supported spelling and loses nothing: it is in scope inside every locus of the seed, so a locus that wants a record of its own declares it above itself and uses it unqualified. A locus-level type had no reading at all before this rule — the resolver registers no member type, so the name it introduced was invisible everywhere, including inside the locus that declared it.

Before this rule, the parser accepted the member and the checker ignored it, so such a program passed hale check and then failed in the backend with locus L member kind not yet lowered to codegen — a program the gate accepted that could not be built (GH #756, the sibling of the member const).

A type is plain data: it is copied by value and has no lifecycle, so it can neither own a locus nor keep one alive. A struct field, or an enum variant’s payload, whose type names a locus — the locus itself, a generic locus’s instantiation (Cache<Int, String>), an array, bounded[T; N] or tuple of it, or a stdlib locus (std::io::tcp::Stream) — is a type error at the field’s type:

main.hl:2:17: type error: `type Layer`: field `w` holds the locus `M`.
A `type` is plain data with no lifecycle: it is copied by value, so it
can neither own a locus nor keep one alive. Hold the locus in a locus
instead: make `Layer` a locus with a `params { ... }` field of type
`M`, or pass the `M` as a parameter where it is used.

A locus lives in a locus: a params field (the owner holds it for its life) or a parameter. An interface is not a locus here: a type may hold an interface-typed field, which is a handle (a fat pointer) rather than an owned locus.

Before this rule the checker accepted the field and the backend refused it with unknown type name in signature and no source location — a program the gate accepted that could not be built.

A const states its type, const LIMIT: Int = 100;, except where the initializer is a literal: const LIMIT = 100; takes the literal’s primitive type (Int, Float, Decimal, String, Bool, Bytes; a negated numeric literal too). Any other initializer without a type is a parse error at the initializer that says to write const NAME: T = …;.

A locus body may not declare a const. const NAME: T = value; is a top-level declaration only (see grammar.ebnf: const_decl is a top_decl, not a locus_member), and a const inside a locus body is a type error at the const keyword:

main.hl:2:5: type error: `const limit` is declared inside locus
`Holder`: `const` is a top-level declaration, not a locus
member. Move it above the locus — a top-level `const` is in
scope inside every locus of the seed — or, if each instance
should carry its own, make it a params field with a default
(`params { limit: ... = ...; }`).

The two spellings the diagnostic names are the supported ones: a top-level const is in scope inside every locus of the seed (one value, shared, compile-time), and a params field with a default gives each instance its own copy (self.name). A locus-level const is neither — it is not per-instance state, so it is not reachable as self.name, and it had no settled spelling for the other two readings (L::name from outside, bare name inside).

Before this rule, the parser accepted the member and the checker typechecked its value, so such a program passed hale check and then failed in the backend with locus L member kind not yet lowered to codegen — a program the gate accepted that could not be built (GH #747).

Every locus type also carries three synthetic members the compiler injects, readable by name from any method body:

Name Type Meaning
children [ChildType] the accept’d-child collection (F.11); self.children.count / .is_empty summarize it
k_max Float the F.1 displacement bound computed from B / c / sigma / phi
draining Bool the F.27 drain flag, true once the locus is winding down

self.<name> resolves the synthetic member before any member the locus declares, so these three names are reserved: a params field, member fn, or capacity slot spelled children, k_max, or draining is a type error at its declaration, naming the synthetic member it collides with and suggesting a rename. The rule is unconditional — it holds for a locus that accepts no child type as much as for one that does, because the synthetic member is resolved in both.

The reservation is per-locus-namespace, not per-spelling: a type’s struct field may be named children (types carry no synthetic members), and so may a local binding or a fn parameter.

Cell<T> is the value type returned by acquire() (Pool slots) and alloc() (Heap slots), and accepted by release(c) / free(c). It is not user-spellable in source — there is no let x: Cell<Int> = ...; syntax. The type appears only at typecheck and codegen.

Aspect v1 behavior
LLVM repr ptr — a typed pointer to T’s struct layout
Element type The boxed inner type carries T from the slot’s of T declaration; Cell<Int> and Cell<Float> typecheck distinctly.
Validity surface Round-trip only: a value can flow through let-bindings, get re-supplied to release / free, and live inside the locus body.
Forbidden ops println, arithmetic, comparison, fn-return-boundary crossing. Printing a cell (println, print, to_string, an f-string) is a type error at the cell; the others reject with a focused build-time diagnostic.
Field access (v1.x-2) Struct cells support cell.field reads and cell.field = v writes; lowers to struct GEP + load/store, and a read types as the record’s field. Primitive cells (Cell<Int> etc.) have no fields: c.foo is a type error at the field name.
Slot-of-origin tracking (v1.x-5) Cell<T> carries both T AND the originating (locus, slot) pair. Releasing a cell into a different slot than it came from is a type error at the cell, naming the originating slot.

The checker follows a cell from the slot call that makes it (self.entries.acquire()) through the let bindings that hold it; those are the cells its rules see.

An interface I { fn ...; ... } declaration introduces a structural interface type I — a named set of method signatures. A locus L satisfies I iff for every method in I, L declares a method with the same name, the same arity, compatible param types, and a compatible return type. Satisfaction is implicit: there is no impl I for L declaration.

Interface types appear in fn parameter positions:

fn render(sink: Sink) {
sink.line("hello");
}

The structural-impl check fires at every call site where a fn declares an interface-typed param: missing-method, arity- mismatch, param-type, or return-type mismatches all produce typed diagnostics at typecheck time.

An interface may also be the type of a locus’s accept and release param (accept(c: I)): the locus then accepts every locus satisfying I, by the same rule, resolved statically per concrete type, never through a vtable (semantics.md § Locus instantiation, “An interface accept”).

Inside the fn, the parameter’s local IS the interface: it offers exactly the interface’s methods, and nothing of the locus behind it. A field read (sink.path) or a method the interface does not declare (sink.flush()) is a check-time error naming the interface and its methods; a local bound from the parameter (let s = sink;) is the interface too (friction sweep 2026-10-12; until then the parameter typed as unknown, the check passed such a read and the build refused it). A fn or locus-method parameter has this typing, and so does a let that declares an interface, an array, bounded or tuple element declared as one (let gs: [Greeter; 2], fn f(gs: [Greeter; 2])), and a stdlib interface written as its path (h: std::http::Handler); each such slot still accepts any satisfying locus where it is declared (GH #2005: until then these read as unknown, and the check passed what the build refused).

A value of an interface converts into no OTHER interface: passing one where another interface is expected (via(gs[0]) with fn via(x: Other)) is a check-time error at the argument, even when the two declare the same methods; declare the parameter as the value’s own interface, or pass the locus. Nor is a locus assigned to a place of an interface (g = Hey { }; for let mut g: Greeter, an element of an interface array, an interface field): the conversion happens where the place is declared, and the assignment is refused at the value (GH #2005).

Fallible methods (GH #732). An interface method may declare fallible(E) after its return type, as a fn does:

interface Store {
fn put(k: String) -> Int fallible(StoreError);
}

A call through the interface is a fallible call: or <fallback>, or handler(err), or raise and or discard apply as on a direct call, and a call that does not address the error is rejected. Which methods satisfy one:

A mismatch is a check-time error naming both signatures. An imported interface keeps its methods’ error types and enforces them the same way. The vtable slot of a fallible interface method holds a callee with the fallible locus-method ABI (i1 return, out_val / out_err slots); for an infallible method, the compiler puts a small adapter with that ABI in front of it.

v0.1 scope (Phase A + Phase B). Interface declarations parse, register, and the typechecker enforces the structural rule (Phase A, shipped 2026-05-10). Codegen vtable dispatch (Phase B) is shipped 2026-05-11. Interface values are fat pointers {data, vtable} allocated in the current arena; the data slot holds the underlying locus pointer (same single-ptr ABI as LocusRef) and the vtable slot holds a per-(locus, interface) static global of fn pointers indexed by interface- method declaration order. A locus flowing into an interface slot coerces at the call site; method calls on an interface value lower as indirect calls through vtable[i] with the data pointer passed as the implicit self arg.

Interface values are usable as fn parameters, fn returns, locus param / field values, and @form(vec) cell elements. Method-call receivers, polymorphic return through control flow, and pass-through aliasing (the original instantiator’s binding and the returned binding refer to the same underlying locus) all work end-to-end. The std::text::Sink stdlib migration (split Sink into StdoutSink / StringSink / FileSink loci behind one Sink interface) shipped 2026-05-11; see spec/stdlib.md and crates/hale-codegen/tests/sink_polymorphism.rs.

The implicit LocusRef → Interface coercion fires at the following positions:

The return path uses two cooperating mechanisms: at the return site, an implicit locus → interface coercion builds the fat pointer, and the locus-instantiation routing extension (the same m90 shape that handles -> LocusRef(L) returns) routes any instantiation of a satisfying locus inside an -> Interface(I) fn body to the program-lifetime payload arena. The fat-pointer struct itself is then deep-copied into the caller’s arena by emit_return_value_deep_copy. Single-element coverage is in crates/hale-codegen/tests/interface_return.rs.

Composite-construction coercion (G20). Interface elements inside fixed-size arrays, array-repeat literals, and tuples are now coerced at the construction site when the destination type is known. The let-RHS with a composite ascription is the wired entry point:

let arr: [Greeter; 2] = [Hi { }, Hey { }];
let arr3: [Greeter; 3] = [Hi { }; 3];
let pair: (Greeter, Greeter) = (Hi { }, Hey { });

The codegen propagates the ascription’s element type through lower_expr_into(expr, hint) so per-position coerce_to_interface fires before the array’s “mixes element types” check would otherwise reject heterogeneous LocusRefs. Tests live in crates/hale-codegen/tests/interface_in_composites.rs.

Once the let-RHS coerces, the array’s static type is already Array<Interface, N> (or the tuple’s positional types are Interface), so flowing it to fn-args, struct fields, or return positions of the same type goes through plain type matching — no further coercion is needed at the consumer side.

Still deferred: locus-routing across nested return positions — a fn declared -> [Greeter; N] instantiating loci inline in its return expression still aliases the fn’s stack frame. Closing that needs the m90 routing extension to fire on nested locus instantiations inside composite returns, the same gap that governs tuple-of-LocusRef escape today.

F.11 child acceptance (accept(c: ConcreteLocus) { ... }) is intentionally NOT in the coerce list above. The child-accept mechanism keys dispatch by exact concrete locus name across substrate sites — accept fn signature, the self.children storage layout, and the parent’s accept-dispatch table — so accept(c: Iface) is a multi-system change, not a coercion wire-up. Single-accept-type per parent is the v1 design.

Interfaces have no default methods at v0; the body is signature- only. No interface inheritance, no multi-interface bounds on generics, no interface equality. F.21 sketches a paired substrate-aware (cascading-dimension) interface form for the n-dim growth case; not implemented at v0.

Lotus is invariant at the type level — no implicit subtyping. A Rich<int> is not assignable to a Chunked<int> even though both wrap int; explicit conversion required.

Exception: contract-graded subtyping (next section).

Numeric coercion: Int → Float (Phase 2c)

Section titled “Numeric coercion: Int → Float (Phase 2c)”

A single documented one-way widening fires at the following surfaces:

The widening is strictly one-way. Float → Int narrowing remains explicit (round + cast). Decimal never participates in implicit cross-type conversion. Only an Int widens: a quantity (5ms is a Duration, spec/units.md) or a range type is not one, so let f: Float = 5ms; is refused. The five surfaces are the whole list: a locus param’s default and a locus literal’s param override (Worker { rate: 3 }) take a Float. The rule was added 2026-05-11 as part of the float-surface-gaps friction-log resolution; see F.23 in spec/decisions.md and the Phase 2c entry in spec/stdlib.md.

Where the implicit widening above does not apply — most often a Float → Int narrowing, or an Int → Float conversion needed in the middle of an expression rather than at one of the coercion surfaces — there are two explicit forms, both round-toward-zero for the narrowing direction (LLVM fptosi / sitofp):

When parent declares consume X: T and child declares expose X: T, the compiler requires:

  • X is the same name in both.
  • The child’s type for X is a subtype of (or equal to) the parent’s expected type.

For v0, “subtype” is just type equality. Future versions may admit covariant / contravariant relationships; v0 is invariant.

This is the F.8 commitment expressed as a typing rule.

Per F.14: any function injected by L into its arena that satisfies a contract entry must return the contract’s typed surface. The compiler verifies, for each contract expose X: T declaration:

  • L has either (a) a param named X of type T, OR (b) a fn returning T named X (or an annotated impl), OR both.
  • Multiple impls (the projection-class-specific case) are permitted; all must return T.

Default-implementation rule: if no fn is annotated, the param named X is the default implementation (read field directly).

Per F.E (design-rationale): bindings are immutable by default. let x = 0; produces an immutable binding. let mut x = 0; produces a mutable binding; reassignment permitted.

Mutability is a per-binding property, not a per-type property. There’s no Mut<T>; the binding either is or isn’t mut.

mut gates every write into a let binding’s value, at any depth (GH #2022). let p = Point { x: 1, y: 2 }; p.x = 99; writes into the value p was declared not to change, as xs[0] = 7 through let xs does and push(d, 5) into a let bounded list does: declare the binding let mut. The rule is Rust’s, and it is what “immutable binding” says. A field or element write through a let (a plain assignment or a compound one, p.x += 1, l.a.y = 3, xs[i] = v) is an error at the write (“`p.x` writes into `p`, which is declared with `let`; declare it `let mut p`”). It is no aliasing rule: a write into a local never reaches the place it was read from (§ “A local bound from a place is yours”), with or without mut.

The rule reads the let. A parameter, a for element and a match payload have no mut spelling and stay writable as § “A local bound from a place is yours” describes; a write through a parameter of caller storage is spec/memory.md’s. A binding that holds a locus (a handle: let c = Counter { }; c.n = 4;, a generic locus’s let c: Cell<Int> = …, through an alias too, or a binding typed as an interface a locus is held through), or a place on the way to the written one that holds a locus (ls[0].n = 4 through let ls = [Counter { }]), writes the locus’s state, as self.n = 4 does, and a cell from a capacity slot names the slot: the rule reaches neither. Nor does it reach a binding whose type the check could not settle (its initializer is itself an error, or names a declaration the checked files do not hold): such a binding may hold a locus, and the error it would raise belongs to the initializer. A generic fn’s binding of a parameter’s type is judged at each monomorph, with the argument bound: the write is refused where T is a record or an array, and is the locus’s state where T is a locus.

For params / locus state, the implicit rule is that fields are mutable through self.x = ... (per F.3). The locus’s state is the locus’s mutable bundle.

An assignment target names declared fields only. Each field of a place’s path (self.x, self.j.rec.p.a, r.ps[0].b, h.repo through a handle) is resolved as a read of it is: a field the record or the locus’s params does not declare is refused at the field with the read path’s diagnostic (“no field `record` on `Inner`”, with a near name when there is one), and the value is held to the field’s type. Until 2026-10-17 such a target checked clean and only the build refused it (“no field `record` on `self.j`”).

Reassigning a locus-typed field is a lifecycle transition. A field that holds a child locus (params { conn: WsClient = WsClient { … }; }) can be whole-value reassigned from a member fn (self.conn = WsClient { … }). Because a locus is not a plain value — it owns a region and possibly @ffi-acquired resources — this is lowered as dissolve-the-old + construct-the-new, not a pointer store: the previous instance is reclaimed (its drain / dissolve run, releasing its resources) and the new instance is constructed into the owning locus’s arena, owned by the field (so the parent’s dissolve cascade reclaims it). The field always points at a fully-live instance. (Before this rule the new instance was a scope-bound temporary dissolved at the method’s exit — a use-after-free; see WS1#4.) For “same instance, reconfigure,” prefer in-place mutation (self.conn.url = …), which keeps the locus’s identity and resources and is cheaper. v1 limitation: the reassigned instance inherits the owner’s pool; reassigning a field with an explicit non-default placement does not re-apply that placement. The same holds from outside the owner (h.loc = L { … } in a free fn, hs[i].loc = L { … }, GH #1561): the store is the owner’s, so the old child is reclaimed and the new one is built as the owner’s field, exactly as the owner’s own self.loc = L { … }. A field initializer of that literal may not read self in another locus’s method (it would read the owner); bind the value to a local first.

Per F.1 / F.3: the compiler computes k_max = B / [(1 - phi) * c + phi * sigma] from the locus’s declared params. This determines the maximum coordinatees an accept() can attach.

If params are constants (compile-time-known), k_max is a compile-time integer. The compiler may reject accept call sites that statically exceed k_max. (For dynamic params, the runtime checks at each accept; exceeding k_max raises a typed KMaxExceeded failure handled by the parent’s on_failure.)

bounded[T; N] — fixed-capacity collections in types

Section titled “bounded[T; N] — fixed-capacity collections in types”

Types are pure data, so they cannot hold a @form(vec) (a locus). bounded[T; N] is the type-level collection: a fixed-capacity counted buffer laid out inline as { i64 len, [N x T] } — the capacity is part of the type (K made value-level, the F.22 philosophy). Works in type fields and locus params.

Operations are GRAMMAR INTRINSICS (like len(s)), not methods, so the types-have-no-methods axiom holds (the one exception, the text types’ receiver calls of std::str and std::bytes fns, F.59, is the path call spelled on the value, spec/semantics.md § Receiver calls on text values):

push(f, x) -> () fallible(CapacityError) // full = error;
// displacement policy
// lives in the or-arm
at(f, i) -> T fallible(IndexError)
set(f, i, x) -> () fallible(IndexError) // overwrite live slot
count(f) -> Int
clear(f) // len = 0
truncate(f, n) -> Int // len = clamp; returns it
for x in f { } // iterate live slots
f.get(i) -> T fallible(IndexError) // = at(f, i); see below

get is the one operation in method position, and the same is true of [T; N]. f[i] is not an operation of a bounded: an element is read with at(f, i) and written with set(f, i, x), each fallible past the live count, where [i] would have no bound to check against. The check refuses it, in value position and as an assignment target, naming both (“`[i]` does not apply to a `bounded[Rec; 16]`: a `bounded`’s element is read with `at(self.items, i) or …` and written with `set(self.items, i, x) or …` …”); until 2026-11-06 it passed and the build refused it with no file or line. Element chains rewrite to a loop that fetches through the source’s get, so answering that name is what makes a form chainable at all — without it, f.filter(…).count() failed with “no field get” and the type-level collections could not anchor a chain. It is identical to at in signature and semantics (on bounded it is at, bounded by the live count rather than the capacity); at remains the idiomatic spelling for a direct index.

The six free-fn-shaped names are NOT reserved. They dispatch on the first argument’s type, so a program may declare a free fn of any of them, and a declaration whose first parameter is the receiver’s own bounded[T; N] shadows the intrinsic for that receiver type — checker and codegen alike. See tokens.md § Built-in identifiers for the exact rule. f.get(i) is unaffected: method position is not the free-fn namespace.

The element type is one a slot holds inline or by a pointer it anchors: a scalar (Int, Float, Bool, Decimal<S>, Duration, Time, an identity, a range or a quantity), an enum without payloads (its tag), String, Bytes, a struct, or an enum with payloads (a pointer to its cell, { i32 tag, body }). hale check refuses any other at the annotation, naming it: a tuple, an array, another bounded or an interface (“`bounded[(Int, Int); N]`: a tuple, which a bounded buffer cannot hold inline … wrap the element in a struct”). Until 2026-10-13 the check admitted them and the build refused the element type with no file or line, and a payload-free enum, which lowers as a Bool does, was refused too.

An enum element with payloads is owned as a struct element is (GH #1951): a push, a set, an array literal, a whole copy of the list, a list returned by value and a list built into a locus store the place’s own copy of the cell and of what its variant carries (a String, a Bytes, a record, a nested enum’s cell), and an element that stops being one — the one set overwrites, the ones clear and truncate drop, every element of a list replaced whole or dissolved with its owner — is retired with everything under it, by the variant its tag names. at, a for element and a match on either read the place’s cell; a value kept past a write to the place is the reader’s own copy, as a struct element’s is (§ Any binding of a place keeps its value). Until 2026-11-15 the check refused the element type (“an enum with payloads, which a bounded buffer cannot hold inline”). A bus payload does not carry a bounded of them (it carries no bounded of pointers, spec/semantics.md § The bus wire format), and an API codec carries no list of them (spec/api.md § Codecs).

Semantics:

  • An array literal at a declared site is a bounded (GH #1951). Where a bounded[T; N] is declared — a let ascription, a return from a fn declared to return one, an argument for a parameter of one, an assignment to a place or local of one, a record literal’s field — [e1, …, ek] with k <= N is that list, its count k, and [] is the empty one. Each element flows into T from its own type (an Int widening into a Float as a push widens it), and an element spelled with a generic template’s name takes T’s arguments, as an array literal’s element does ([Row { v: 7 }] at bounded[Row<Int>; 4]; until 2026-11-17 the check refused it, naming Row and Row_Int). A literal longer than the capacity is refused where it stands (“a `bounded[Int; 2]` holds at most 2 elements, and this literal has 3”), and so is an element of another type, at the element. The list owns its elements, as push stores one: a pointer-shaped element that is not a fresh value (a local, a field, an element read) is stored as the list’s own copy. An unannotated let xs = []; declares no list; the check refuses it, as any [] with no declared type (§ What the compiler cannot compile yet). The type written as a value (let x = bounded[String; 4] { };) is a parse error at bounded[String; that names this spelling (GH #1948).
    type Doc { tags: bounded[String; 8]; }
    fn tags_of(d: Doc) -> bounded[String; 8] { return d.tags; }
    fn main() {
    let ids: bounded[Int; 4] = [1, 2, 3];
    let mut tags: bounded[String; 8] = [];
    push(tags, "a") or discard;
    let d = Doc { tags: tags };
    println(count(ids), " ", count(tags_of(d)));
    }
  • Fields auto-initialize EMPTY, and a field takes no default: the check refuses one at the default (“type `Doc` field `tags`: a `bounded[String; 8]` starts empty and takes no default …”), where lowering evaluated none and the field started empty whatever the default said. An absent list decodes as empty. Whole-STRUCT copies carry elements + count by construction (the storage is inline).
  • A local is the frame’s own list. One bound from a literal or a call’s result is fresh; one bound from a place is a copy (§ A local bound from a place is yours). A let mut local is assigned whole (xs = ys;, xs = [];, a copy of the value unless it is fresh) and written by the intrinsics; an intrinsic that writes a local declared with let is refused at its argument (“`d` is a `bounded[String; 4]` local declared with `let`, and `push` writes it: declare it `let mut d` …”), so a program written against the view a bounded local was before F.49 is told where it no longer writes the place. A local’s storage is a block of the frame’s arena, never a stack slot, whatever its capacity.
  • A fn returns a bounded by value (GH #1951): a free fn, a locus method and an interface method may be declared to return bounded[T; N] (written, or through an alias), and return its storage as a record is returned, a pointer into the caller’s arena. Every return copies the list there, its live pointer-shaped elements with it (an element already in the caller’s arena is kept), so a String or record a member’s scratch built reads whole after the call. A call’s result is a temporary the intrinsics read (count(tags_of(d)), at(names(), 0) or …, for x in names()); one that writes it is refused at the argument (“a call’s result is no place to push into …”): bind it to a let mut local first. Until GH #1951 the check refused such a declaration and a record holding the bounded returned it.
  • Its live count is count(x); len does not apply to a bounded (written or through an alias), and the check refuses it, pointing at count (“`len` does not apply to a `bounded[String; 4]`: a `bounded`’s live count is `count(x)`”), where the build refused it with no file or line until 2026-10-18.
  • The other way round, an intrinsic’s name called on a first argument that is not a bounded, with no fn of that name declared to answer it, is refused by the check at the call, naming the argument’s type and, for a record holding a bounded field, that field (“`count` does not apply to a `Bag`: it is an intrinsic of a `bounded[T; N]`, and no `fn count` is declared for this argument — its field `items` is a `bounded[String; 4]`: `count(b.items)`”). Until 2026-11-14 count(record) passed the check (count is a bare callee the check admits for the accumulator vocabulary, count()) and the build refused it as a call to an unknown free fn, with no file or line. An argument whose type the check does not know (a generic parameter) is left to the build, as before.
  • A bounded place (a field, a locus param) is assigned whole only from a value of its own type, bounded[T; N] with the same T and N: row.models = req.models copies the count and the live slots, and each pointer-shaped element is anchored in the place’s owner’s arena, as push anchors the one it adds (the holding locus’s arena, else the current one). It is a copy: a later intrinsic on either side does not reach the other. A value read from a place (a field, a local, a parameter, an element) gives the place its own copy of every element, all the way down (a record element a fresh block with fresh blocks below it, a String or Bytes copied), as a record literal’s field (Row { tags: r.tags }), push and set do; a fresh value’s elements (an array literal’s, a call’s result’s) are kept as they are. So no write below an element of one list, through a local or through a parameter it is handed to, shows in the other, and a record built that way holds nothing of the place’s. Until GH #2099 a place no locus holds (a record local’s field) kept an element already in that arena, so the two lists shared their elements’ blocks, and a callee writing below an element of one changed the other. An array literal builds the value it copies (above); any other value (another element type or capacity) is refused at the assignment (“a `bounded[String; 4]` is assigned whole only from another `bounded[String; 4]` or an array literal …”). Until GH #1951 a bounded local was not assigned whole: it was a view of the place it was bound from. Until 2026-10-17 every whole assignment was refused, with no ruling behind it but a lowering that had none, so a copy between two records’ fields was a push loop.
  • Scalar elements (Int/Float/Bool/Decimal/Duration) are flat under zero_copy and travel the bus as raw bytes. A Time element is the i64 a Duration is and lowers inline the same way; it is not flat under zero_copy, as [Time; N] is not (semantics.md § Payload-shape compatibility). Pointer-shaped elements (String/Bytes/struct/an enum with payloads) work in-process — push/set arena-anchor the element into the receiver’s owning arena — and cross the bus as a count and that many elements (semantics.md § Payload type, GH #1951 item 4); they are not flat under zero_copy.
  • A bounded place a locus holds (a field of its, or a field of a record it holds) owns its pointer-shaped elements, as the record owns its String fields: push, set and a whole assignment store the place’s own copy of each (a String already in the locus’s arena is copied too, a record element is always a fresh block), and an element the place stops holding is retired into the locus’s arena — the one a set replaces, the ones a clear or truncate drops, the ones a whole assignment of the place replaces, and every live one of a record the locus replaces whole (self.r = v, with r holding the bounded), or of a @form cell holding one that is replaced or removed (spec/memory.md #6). Only the live slots, [0, count(x)), are elements: a slot past the count is never read and never retired. at(x, i) hands back the element itself, so a binding of it held across a write that may replace it (a call that stores the field, a set) is an owned copy, as any binding of a place is (§ “Any binding of a place keeps its value”); a for over such a place walks its own copy when its body may replace the place. Until 2026-11-11 none of these retired: a locus storing a record of one 8 KB String in a bounded[String; 4] back over itself grew by that String per store, for its lifetime.
  • Every bounded place owns its pointer-shaped elements, a local’s too (l.list, with l a record local): no slot holds a block another name reaches, so push(l.list, y); y.k = 2 leaves the element as it was pushed, and writing an element read with at and set back leaves y as it was. push and set store the value they are handed only when nothing else names it: a literal, a constructor, a call’s fresh result, a String or Bytes local holding one (nothing writes into a String under a local in place), or a value no one reaches after the store: a local of the frame that is not read or written after it (nor in a later iteration of a loop it was declared before) and that no binding live after it views, holding a value only it names (a fresh one, or a copy made at its binding or at its first write), or a part of such locals, all the way down (an element of a list a for walks that nothing reads again, a literal of a dead local’s fields; not one of a record copied whole from another still read, which shares its lists’ elements). A slot set back, let mut x = at(l.xs, i) or …; x.f = y; set(l.xs, i, x) with x used no more, is stored as it is too: x holds the slot’s own element, written in place where § “A local bound from a place is yours” keeps the write there, or the write’s copy of it. Anything else — a local used after the store, a parameter, a field or element of a value still read, a literal holding a local still used — is stored as the list’s own copy (a record element a fresh block, deeply; a String or Bytes copied), which the allocation survey reports as a store’s copy (copy: a value another name reaches stored into a bounded list). A call’s result fresh at its top level that holds another name’s block in a part is copied too: fn wrap_of(r: Row) -> Wrap { return Wrap { t: r.t }; } hands back r’s own Tag block in t, and the list takes its own copy of it. The survey reports it as copy: a call's result holding another name's block stored into a bounded list; until GH #2067 it carried the first reason, whose advice named a call’s result as a value nothing else names. A part is a block by its layout: a record, a bounded list’s elements, an enum with payloads. A bounded field given a place’s list whole (v.tags = r.tags; return v;, return Sum { tags: r.tags };) holds copies of its elements (above), so such a result is fresh and stored as it is; until GH #2099 the whole assignment kept r’s elements and the list copied the result. A field that is an inline scalar slot (a number, a Bool, a Time, a unit or scalar declaration, a payload-free enum, which is its tag) is copied with the record and holds nothing of the argument’s, so fn s_of(r: R) -> S { return S { n: r.n, st: r.st }; } with st a payload-free enum is a fresh result, stored as it is; a String field taken whole (s: r.s) is a leaf no write reaches, and is stored as it is too. Until GH #2088 a payload-free enum field counted as a block, so that push was reported, and copied, as one holding the argument’s block. A local’s list does not retire what a set replaces: the frame’s arena frees it with the frame. A whole assignment into a record local’s field does retire the copy it replaces, when no other name can reach it (GH #2105): the copy is made in an arena of the field’s own, and the next such store frees it. Only those stores allocate there, so a block that reached the field any other way (a push of a String a local still holds, a fresh value bound as it is) is never freed by it. A store keeps the frame’s arena when a name in scope where it runs may hold a block of an earlier copy: a binding read from the field (let t = at(q.tags, 0) or …, a for over it, let w = q), or, transitively, a place such a value was stored into, pushed into or handed to a callee beside. None of the local’s stores into the field retire when such a value lands in another field of the local or the local is handed whole to a callee, and no store retires that sits inside an expression, whose value reads the field, or that is in no loop of its body (it runs once per call, with no earlier copy of its own to free: v.tags = r.tags; return v; is copied as before) (hale_types::field_retire). Until GH #2105 every whole assignment’s copy stayed in the frame’s arena until the frame ended: q.tags = r.tags 200,000 times over a local declared before the loop held 117 MB. Until 2026-11-12 only a place a locus holds copied: a local’s list kept the very block it was handed, and a write through either name showed through the other (GH #1918).
  • A pointer-shaped element pushed or set into a bounded place under a parameter is kept in the frame that runs the call: a free fn allocates in its caller’s arena (a fn that takes a record is never scratch-local), a locus member in its own scratch. So a locus member doing it is refused at the intrinsic (“push of a `String` element into a bounded place under a parameter of a locus member …”), and a free fn doing it, directly or through a fn it hands the place to, is refused at a call that hands it a place the frame does not own: one under self (“`fill` stores pointer-shaped elements … this argument is a place in this locus’s arena …”). A call through a function value is the fn the value’s binding names (let f = fill;, a tuple let’s element of a tuple literal); a binding the body assigns (f = other;), a parameter of fn type or a computed callee names no one fn, and such a call is refused for any argument holding such a place. Names are bindings, not spellings: an inner let f names nothing after its block, and let r = r; is an owned copy, not the parameter. A generic fn is read as any other, its type parameters taken as any type (fail closed): a field path through one (fn fill<T>(r: T) { push(r.xs, s) }) may be such a place, so fill(self.row) is refused (a local bound from it, let mut dst = r.xs, is the frame’s own copy since F.49, and writing it writes no place); a type parameter is the fn’s own, whatever global type shares its name. A record of the frame’s own, a copy of one, and a scalar element are sound; the shape that works for a locus’s field is to fill a local and store it whole (self.row = mine), which anchors the elements in the locus’s arena. The stdlib’s std::http::is_route writes its captures into ctx.params this way, so a context a locus holds is refused as its argument (2026-10-17: it was a use-after-free).
  • Drop-front/FIFO is the shift-left idiom: set live slots down, then truncate.
  • CapacityError { cap: Int; count: Int } and the shared IndexError are the injected error shapes.
  • The unbounded-alloc analysis treats bounded fields as bounded by construction. @form(vec) remains the unbounded, locus-owned collection: unbounded data lives on a locus; bounded data can live in a type.
  • A wire map (2026-10-17): checks: bounded[Check; 16] indexed_by name; keys the list by its elements’ name. It is the same bounded list in the program (iterated, pushed, read by index); only the api codecs read the clause, which carry it as an object keyed by name (spec/api.md § Codecs). The clause has the @form(hashmap) slot clause’s spelling and rules: the field is a bounded[T; N], T a user-declared struct, and the named field a String field of it; any other shape is refused at the clause (`indexed_by` on `Health.checks`: key `Check.n` is a `Int`: a wire map's key is a `String` ...). Nothing keeps the keys distinct in the program; a duplicate key is refused when a payload is decoded, and an encoder writes what the list holds. indexed_by name -> status (2026-10-19) names the value of a map of values, each element crossing as its status alone. The element has the key and that field and no other, and the value is a scalar, a Time or a payload-free enum. Anything else is refused at the clause (`indexed_by` on `Health.checks`, its value `-> status`: `Check` has other fields (detail), ...).

Generic type-expr ↔ monomorph unification: a generic instantiation type-expr (Box<Int>) resolves at typecheck to its mangled monomorph name (Box_Int) — the same name codegen synthesizes and that Box_Int { ... } literals produce — so declarations and literals unify, and a Box_String literal in a Box<Int> slot is a caught mismatch. Monomorph literal fields validate against the template with the type args substituted, and field reads on monomorph values type as the substituted field.

A generic fn’s result that applies a template to its parameters (fn box_of<T>(x: T) -> Box<T>) is, at each call, the monomorph the call’s arguments name: box_of(Blob { … }) is a Box_Blob, its field v a Blob, as the build lowers the call (GH #1978). A result whose arguments the call leaves unknown stays unchecked.

An imported seed’s template and enum through the qualified alias path are held to their declarations as the bare spellings are: lib::Box<Int, String> against type Box<T> is refused for its argument count, and lib::E::V(…) for its value count and each value’s type, a scale-less Decimal literal taking the payload’s scale (GH #1986).

A declared type parameter shadows a same-named top-level declaration or alias throughout its template’s signatures, fields and body annotations. Before specialization it remains unbound; a global name cannot supply its type or create an apparent concrete monomorph.

Generic loci monomorphize the same way. locus Cache<K, V> is a template; Cache<Int, String> names the monomorph Cache_Int_String, whose params are the template’s with the arguments substituted. A parameter is substituted wherever a field’s or a param’s type writes it: bare (T), as an argument (Row<T>), or as the element of an array, a bounded[T; N] or a tuple, so type Page<T> { items: bounded[T; 50]; } at Page<Int> holds a bounded[Int; 50]. Until 2026-11-17 a bounded’s element kept the parameter, and the build refused such a record (“generic-type dependency cycle … Page_Int”) or locus (“unknown type name T in signature”) after a clean check. A field read on a monomorph locus value (c.cap) types as the substituted param, exactly as a monomorph struct’s field read does.

Generic function calls inside a generic locus are typed for each concrete locus monomorph. A call on self.value, or on a local bound to that field, uses the substituted field type. The checked call rows retain their source body and call identities; lowering selects the row for that locus’s arguments. Params defaults use their declaring locus’s specialization even when construction happens inside another generic function or locus. Specializations discovered in these bodies are checked in turn.

Omitted function and method defaults are typed at each invocation that leaves them. Their generic call rows retain the default’s source site and distinguish the invocation path and the caller’s specialization. A default reads only its constants and the module’s items (§ Locus params), so every invocation types it alike. Lowering reads the corresponding checked row; supplied arguments do not evaluate the default.

Where the arguments come from. A struct / locus literal spelled with the template name (Box { value: 1 }, Cache { cap: 2 }) carries no type arguments of its own; it takes them from the declared type at the site. The sites that declare one are:

  • a let ascription — let c: Cache<Int, String> = Cache { cap: 2 };
  • a declared return type, at a return or the body’s tail — fn make() -> Box<Int> { return Box { value: 4 }; }, fn make() -> Box<Int> { Box { value: 4 } }
  • a declared field or param, at its DEFAULT — params { b: Box<Int> = Box { value: 0 }; }
  • a declared field of a data type, at a literal’s init — Outer { inner: Box { value: 9 } }
  • the place of a plain assignment (=, not +=) — self.cfg = Cfg { n: 2 };, a local, a record’s field or an array’s element, by the place’s declared type

An array ([x, y] or [x; N]) or tuple literal at one of these sites hands each element the declared element type, so its template literals take that type’s arguments: let cs: [Cfg<Int>; 2] = [Cfg { n: 1 }, Cfg { n: 2 }];, let rs: [Cfg<Int>; 3] = [Cfg { n: 0 }; 3];, let t: (Cfg<Int>, String) = (Cfg { n: 1 }, "a");, and a param default of array type (params { cfgs: [Cfg<Int>; 2] = [Cfg { n: 1 }, Cfg { n: 2 }]; }).

At a let ascription, a transparent alias of the whole instantiation supplies the same arguments: type IntBox = Box<Int>; permits let b: IntBox = Box { value: 1 };. Imported template paths resolve through their import aliases before specialization. Different aliases for one imported template retain the same declaration identity; each construction carries its own concrete arguments and child layouts.

The literal’s fields are then typed as the instantiation’s: a field whose declared type mentions a parameter holds a value of the type the arguments make of it, so with b: Box<Int>, b = Box { value: "x" }; is a type error at "x" (type Box: field valueexpectsInt, got String``), wherever the literal stands. An Int widens into such a Float field of a data type, as into any data literal’s (F.23), never into a locus param’s.

Anywhere else — an un-annotated let (of the literal, or of an array or tuple literal holding it), a literal in statement position, a receiver (Box { value: 1 }.value), a call’s argument (a generic fn’s included), an operand, a condition, an f-string part, the arm of an if or match expression — the arguments cannot be recovered, and the literal is a type error, at the literal, naming the template and the annotation to write (GH #1965):

main.hl:6:13: type error: `Box` is a generic type: a literal spelled
with the template name takes its type arguments from the declared type
at the site, and nothing here declares one. Bind it to a `let` that
writes them (`let x: Box<T> = Box { ... };`) and use `x`

There is no inference from a literal’s field values back to the parameters.

A generic instantiation’s argument COUNT must equal the template’s parameter count: Box<Int, String> on type Box<T> is a type error at the annotation.

The mangled monomorph name is spellable for a generic TYPE (Box_Int { value: 1 }, and through an alias — type IntBox = Box<Int>; IntBox { ... }). It is not spellable for a generic LOCUS: Cache_Int_String { cap: 2 } is a type error pointing at the template spelling.

Generic params are declared with angle brackets:

fn apply<T, U>(x: T, f: fn(T) -> U) -> U { ... }
type Box<T> { value: T; }
locus Cache<K, V> { params { cap: Int = 1; } }

A locus’s method is not generic itself: fn twice<T>(...) inside a locus is refused by hale check at the method’s name (hale can’t compile a generic locus method yet); declare it as a free generic fn, or make the locus the template.

Calling a generic fn. A call binds each type parameter from the argument in the position that names it, and the specialization is the one those arguments name. The same holds for a generic fn another seed declares, called through its import alias (lib::id(3), for its value or as a statement), and for a generic fallible(E) fn under or (parse(s) or 0, lib::parse(s) or raise), which specializes as a plain call does and is addressed like any fallible call (GH #1964, #1966).

An argument whose type the checker cannot name pins nothing: a capacity slot (id(self.registry): a slot is used through its operations), a call that returns no value (id(println("x"))), a stdlib path written without std:: (id(time::sleep(5ms))). A generic call whose parameter only such an argument could pin is a type error at the argument (GH #1963), naming what it is, or asking for the value bound to a let that writes its type. Inside a generic body a use of its own type parameter is unnamed until a call specializes it, so there the rule is held at each specialization: a local the body still cannot name at the type arguments a call makes is refused at the argument (GH #2005). A match arm’s binding is named there: it is of its variant’s value type at the specialization (GH #2016; until then Link::Next(n) -> id(n) over a recursive record was refused, the binding unnamed).

A call fills no default on a generic fn’s parameter: a call that leaves a defaulted parameter out (fn read<T>(n: T = 42) -> T called as read()) is refused at the callee, naming the parameters to pass. A call written in another fn’s parameter default (fn f(n: Int = read())) is held to the same rule (GH #2005; the default’s walk kept no findings, so the check passed it and the build refused it where the default is left out).

A generic body is checked at each specialization. The template is checked once with its parameters unnamed, and again for each set of type arguments its calls make; a return (or a body’s value) that does not type at those is refused at the value, naming the specialization (fn scale<T>(x: T) -> T { return x * 1.5; } called with an Int: “return: expected `Int`, got `Float`, where a call makes `T` = `Int`”; GH #2005), and so is a value that is () only there (a generic locus’s id(self.child.go()) at a T whose go returns nothing). Inside the specialization, Time ± Duration, Time - Time and a Decimal literal beside a Decimal<S> operand lower as they do in a body written over the concrete types.

A generic fn has no single type, so its name is not a value: let g = get; (or passing get as an argument) is a type error at the name (GH #1976). Call it, or pass a fn written over the concrete types that calls it.

The constraint syntax <T: Bound> admits one bound, Numeric: the argument is Int, Float, a Decimal or a Duration (type Box<T: Numeric> { value: T; }, fn twice<T: Numeric>(x: T) -> T). hale check holds it where the template is instantiated — at the argument of a type annotation (Box<String>), and at the callee of a generic fn call whose arguments bind T to another type (an identity or a range included: it is a named argument) — and refuses any other bound name at the declaration (<T: Eq>, <T: SomeStruct>): there is no trait system. An argument that is itself a type parameter of the enclosing template is held where that template is instantiated.

main.hl:7:20: type error: generic type `Box`: `T` is bounded
`Numeric`, and `String` is not one of `Int`, `Float`, `Decimal` or
`Duration`

Monomorphization: the compiler emits one machine-code instance per concrete generic instantiation (per F.1 commitment to runtime perf over compile-time perf). Compile times grow with generic surface; runtime is full-speed.

A monomorph has to be NAMED before it can be declared — Box<Int> is lowered as Box_Int — so each argument must contribute a token to that name. The name is the template’s, then each argument’s token in declaration order, joined by _ (Template_Arg1_Arg2: Cache<Int, String> is Cache_Int_String, Box<Pair<Int, Bool>> is Box_Pair_Int_Bool). The primitive vocabulary is:

Int U64 Float Bool String Duration Decimal U256 I256 Time
Bytes BytesView BytesMut StringView

Decimal stands for every scale: Decimal<S>’s token is Decimal<S> without the brackets (Box<Decimal<18>> is Box_Decimal18), and plain Decimal’s (Decimal<9>) is Decimal.

Every primitive is a generic argument (Box<U64> is the monomorph Box_U64). Until GH #2121 one was not: the reserved Uint had no codegen representation in any storage position, so hale check refused it as an argument at its span; U64, which replaced it, has one.

A non-primitive argument is a single-segment named type (a user type, or another generic instantiation, which mangles recursively). An identity or a range (spec/units.md) is one too, and lowers as the integer it counts. A quantity or a point declared by the program is not: its unit lives in the checker’s rows for the places that name the type, and a generic body names T, so it would print and convert as the bare count. A generic fn call that would bind one is refused at the callee (“generic fn `id`: `T` would be `Money`, a quantity, and a generic body has no unit to print or convert one by”); the stdlib’s Duration and Time are primitives and bind. A locus or an interface binds too: the specialization takes and hands back the handle, as a fn declared over the locus or the interface does (let c = id(Counter { n: 3 });; GH #1974). A locus handed where the interface it is held as is the bound type (id(c) with c: Job in a release(c: Job)) is passed as that interface (GH #1975).

A generic type’s argument is never a locus: Box<L> would make a type hold the locus L, and a type is plain data that can neither own a locus nor keep one alive (the rule a type’s field of a locus type follows). hale check refuses it at the argument of the annotation, a generic locus’s instantiation as a plain locus (Box<Cache<Int, String>>, at Cache<Int, String>), and refuses a generic fn call that binds a parameter to a locus where the fn’s signature instantiates a generic type at that parameter (fn bx<T>(x: T) -> Box<T> called with an L), at the callee; the build refused the monomorph with no location. A generic locus’s monomorph is a locus too (bx(c) with c: Cache<Int, String>). A generic locus (locus Box<T>) holds one.

An array, a tuple, a bounded[T; N] or a function type names no monomorph, so a generic fn call whose arguments would bind one is refused by hale check at the callee (GH #1942):

main.hl:2:21: type error: generic fn `id`: this call makes `T` `[Int; 2]`,
an array, and hale can't compile a generic fn specialized at one yet: a
generic argument is a primitive or a declared type (a struct, an enum,
an alias, a locus or an interface). Wrap the value in a declared type
(`type Wrapped { v: [Int; 2]; }`), or write the fn over the concrete type

A qualified path is rewritten to a single segment by the import renames before the mangler sees it, in a signature and in a body’s let ascription alike: let x: Box<lib::Scalar> = Box { v: 17 }; and let b: lib::Box<String> = lib::Box { v: "x" }; name one monomorph in the check and the build (GH #1964).

A construct hale check accepts is a construct hale build compiles (GH #1942). The few the compiler has no lowering for yet are refused by the check, at the construct, with the words “hale can’t compile … yet” and a way forward, never by the build after a passing check:

construct refused at way forward
an unsized array type [T], or a length that is not an integer literal ([T; N]) the annotation size it with a literal, or hold a varying count in bounded[T; N] or a @form(vec)
a generic fn call that binds a parameter to an array, a tuple, a bounded or a fn type the callee wrap the value in a declared type
a generic locus method (fn f<T>(…) inside a locus) the method’s name a free generic fn, or a generic locus
a generic fn named as a value (let g = get;) the name call it, or pass a fn over the concrete types that calls it
a generic fn call whose parameter only an argument with no nameable type could pin (a capacity slot, a call with no value, a match arm’s binding in a generic body) the argument bind the value to a let that writes its type
a literal spelled with a generic template’s name where no declared type supplies its arguments the literal bind it to a let that writes them
a generic type instantiated at a locus (Box<L>, Box<Cache<Int, String>>, or a generic fn’s -> Box<T> called with an L or a generic locus’s monomorph) the argument, or the callee a generic locus, or pass the locus as a parameter
a call that leaves out a generic fn’s defaulted parameter the callee pass the parameter
an empty array literal [] with no list type declared where it stands: anywhere but the value of a let that declares its type, or a site that declares a bounded[T; N] (a let, a return, an argument, an assignment, a record field; § bounded[T; N]) the literal let xs: [T; 0] = [];, or [x; 0]
a nested pattern inside a tuple pattern (((1, 2), 3) ->, (E::A, 3) ->) the nested pattern bind the part and match the binding (the rule a variant’s pattern follows)
a range index on anything but a String (a[1..3] of an array) the index copy the elements, std::bytes::slice for bytes
sum(…), count(), mean(…) outside a closure assertion; an accumulator over anything but one field (sum(self.a + self.b)); prod(…) anywhere the accumulator spec/semantics.md § Closure tests
a closure band that mixes Int and Float (mean(self.n) ~~ 1 within 2) the Int side write it as a Float

len, Int(…) and Float(…) refuse an operand outside their rows (§ Calls to bare names, § Explicit numeric conversions) for the same reason. The boundaries refuse theirs where they are declared: an @ffi parameter with a default, or of an enum, a locus or an interface type (spec/ffi.md); a bus payload field the wire format has no form for, an enum in a native shm_ring, a Drain<T> handler on a layout: ring (spec/semantics.md § The bus wire format); a cross-pool child whose params the spawn cannot marshal or which keeps work the far side would schedule (spec/semantics.md § Accept bubbling); sort() of a @form(vec) whose cell has no default ordering and a @form(lru_cache) key that is no Int or String (spec/forms.md).

The type of let x = expr; is inferred from expr. Explicit annotation let x: T = expr; overrides inference; if expr’s type is incompatible with T, compile error.

If a fn omits -> T, the return type defaults to () (unit). Explicit -> T is required for any non-unit return.

Params must declare types explicitly. params { x: Int = 0; } is the full form. (Inference of param types from defaults is not supported in v0; explicit is preferred for the inferred-vs- = default distinction.)

Three init shapes:

  • name: T = expr; — default. Used when the caller omits the field; evaluated where the locus is built, at instantiation time. A default reads only its own fields and constants, never the scope of the literal or call that leaves it. That holds for every default: a locus’s param, a record type’s field, a fn’s, method’s or hook’s param. Each name a default reads must be one of these:

    • a module-level item: a constant, a free fn (as a call or a value), a type, a variant, a locus;
    • a builtin, or a primitive’s conversion (Time(3ns));
    • a qualified path (no local is qualified);
    • a name the default binds itself (a block’s let, a match arm’s binding, an or handler’s err), where that binding is in scope: after its let and within its block, within its arm or handler. A read in a let’s own initializer, or after the block that bound it, is not the default’s. The checker answers each of these, typing the default once where it is declared with no binding in scope, as it types it wherever it is evaluated: a word after or is a narrowing’s policy (T(x) or clamp) only where the or narrows, and after any other fallible (parse_int(s) or clamp) it is a name like any other;
    • for a locus’s param only, an earlier param through self.<param>.

    Anything else is refused where the default is written (“a default reads only its own fields and constants; a is in the caller’s scope”): a caller’s local, a fn value bound there, an earlier parameter of the same fn. So is self in a record field’s or a fn’s, method’s or hook’s parameter default, where it would be the caller’s. A default that calls a fn leaving out a parameter, or builds a record leaving out a field, expands defaults held to the same rule where they are declared. Where a literal or call leaves a default out, a caller binding of a name the default reads (a let K beside const K) would be read in its place, so the check refuses that literal or call (“K here is the caller’s binding, …”): rename the binding or pass the value. A default publishes nothing: a <- (or a Topic.write) written in any default (a locus’s param, a record type’s field, a fn’s, method’s or hook’s param) is refused at the send, since the scope that evaluates it holds none of the declaration’s bus (“a publish in a default: …; publish from a hook or a method instead”). A method the default calls may publish. A record literal written in a default is held to every record literal’s rule: it writes each field that has no default of its own, and one that leaves such a field out is refused at the literal (“type T: missing field f”), in any default, by the check rather than the build. A record type’s field default is a value of the field’s type, so one that produces none (type ()) is refused at the default: meta: Meta = { }; is an empty block, not a record literal (“field `meta`: declared `Meta`, default is `()`: `{ … }` alone is a block, and a block with no tail value produces nothing; a record literal names its type: `Meta { }`”). Until 2026-11-14 the check said ok and the build refused it as a block with no trailing expression, with no file or line.

  • name: T; — required. The caller MUST supply the field at the locus literal site; instantiation without it is a compile error. Use for fields where no sensible default exists (e.g. Server { handler: ... } where the handler is the whole reason the locus exists).

    Exception (B7 / G19): if T is a user-defined type (struct) and every field of T has a declared default, the compiler synthesizes T { } as the param’s default. So params { cfg: Cfg; } against type Cfg { host: String = "localhost"; port: Int = 8080; } works without = Cfg { } spelled out. Required-shape is preserved when any field on T lacks a default.

  • name: T : inferred; — F.3 inference path; compiler / runtime determines the value.

T may be another locus (B10 / G24). A param typed as a locus name (params { db: DB; }) stores a LocusRef — a single-pointer borrow. The param-holding locus does not own the referenced locus; the caller keeps it alive. Cross-decl declaration order doesn’t matter: a forward reference (User { db: DB; } declared above locus DB { ... }) resolves via the codegen-side pending_locus_names pre-pass.

Reading through the borrow (self.db.name, self.db.draining) goes through the same field-access lowering as any other LocusRef receiver. Synthetic fields (self.db.k_max, self.db.draining) work on non-self receivers too (B14 / G31).

A locus may not contain itself by value (GH #813). A param default that constructs the locus it belongs to — directly, or around a cycle through other loci — is an error at the param (“param next of Node defaults to a Node; a locus cannot contain itself by value”). Every instance the default builds needs another, and no call site can end the chain: Node { next: ... } needs a Node to hand over, and building one asks the same question again. The rule is over locus LITERALS in a default, anywhere in it — inside an if or match arm or a block’s statements too, since every branch is lowered — and a literal’s own supplied fields count: a default that spells out every param of the locus it builds expands no default of its own and is not a cycle.

A call that builds one counts (GH #870). next: Node = make() with fn make() -> Node { return Node { }; } is the same ring spelled through a function, and the same error at the param (“param next of Node defaults to make(), which builds a fresh Node; a locus cannot contain itself by value”). Lowering a call emits a call rather than inlining the callee, so that program used to compile and then overflow its own stack at run time instead — every Node make builds leaves ITS next to the same default, which calls make again. A fn counts when every value it hands back is freshly built: a literal of its declared locus, a call to another such fn, or a local binding of either — the binding the returned name resolves to, so an inner let that reuses the name does not hide it (GH #1140) — including through an if, a match or a block whose every arm is one of those (return if c { Node { } } else { make() };), the set lowering reads too. A call the compiler cannot see as fresh is not an edge and stays accepted — an accessor handing back a locus somebody else owns (next: Node = registry.head()), a method, a std:: or cross-seed path, a carrier with an arm that is none of those. That program may still recurse at run time; @no_recursion is the contract for unbounded recursion, and this rule only reports the rings it can prove.

A cycle whose loci live in different files of one seed is reported when the seed is checked together, since a single file holds no declaration for its sibling’s types. The test harness’s build, which skips the rest of the check, judges this rule too, so lowering keeps no guard of its own (F.40 phase 3, C7).

A record may not contain itself by value. A record is a value, and every one holds a whole value of each field’s type, so a record that holds its own kind by value, directly or around a ring of records, through a field, a tuple’s part or a fixed array’s element, has no floor: no literal can build one. A field left to a default (child: Cfg = Cfg { }) expands the same default again, and a field the literal must write needs a value of the type being built. The check refuses the declaration at the field that closes the ring, naming each field on it:

main.hl:1:57: type error: a record cannot contain itself by value: `Cfg.child: Cfg` puts a whole `Cfg` inside every `Cfg`, so none can be built. Hold the `Cfg` values a `Cfg` may have in a `bounded[Cfg; N]` (it starts empty), or in an enum variant beside one that holds none (`type Child = enum { Nothing, One(Cfg) };`), or keep them elsewhere and hold a key

A generic record is followed with its type arguments substituted (b: Box<Cfg> with type Box<T> { v: T; } is a ring), an alias to its target. The shapes that give a record of its own kind a floor are not rings, and build: a bounded[Cfg; N] field (it starts empty), and an enum whose variants hold one (child: Link = Link::End with type Link = enum { End, Next(Cfg) }); so are a fn type, an interface and a locus, which hold no record value. The test harness’s build judges this rule too. (Until 2026-11-14 the check said ok and the build expanded the default until the compiler’s own stack overflowed; a record holding its own kind through a bounded or an enum overflowed it the same way at every deep copy, which is now a function of its own per such type.)

Per F.3: a param declared : inferred (instead of = value) indicates the compiler / runtime determines the value, not the author. The compiler treats:

  • Hand-declared = value → prior, fixed at compile time.
  • : inferred → unknown; resolved at compile time if possible (constant propagation), at runtime otherwise.

Typing-wise, inferred params have the declared type; they’re just not bound to a value at declaration time.

Functions are first-class values. fn(A, B) -> C is a type; function literals can be assigned, passed, returned.

A call’s callee is any expression that evaluates to a fn value: a name, a record’s fn field (h.f(x)), and, as of GH #1942, a call that returns one (pick()(2), a.get()(4)), an array element (fs[0](https://github.com/hale-lang/hale/blob/main/spec/4)), a tuple part (t.0(4)), an if or match that picks one ((if c { dbl } else { tri })(5)), or the success of an or ((pick() or raise)(4), GH #2005). The callee is evaluated once, before the arguments, each passed as at a direct call (an array literal for a bounded[T; N] parameter is that bounded, GH #2005). A fn value returns any value type, a view’s included: a StringView comes back through a fn value or an interface method as through a direct call.

A locus’s fn member can be a method (takes self) or a free function within the locus’s scope. Lifecycle methods (birth, accept, etc.) are not regular fns — they have their own syntax and don’t take self (it’s implicit).

A function value is a free fn’s name read as a value (apply(dbl, 1)). A method is not one: it is called on its locus, and a fn(A) -> B value carries no locus, so self.dbl (or h.dbl, an interface’s method) written anywhere but a call’s callee is a type error at the method’s name:

main.hl:3:33: type error: `.dbl` is a method of the locus `App`,
written as a value: a method is called on its locus (`….dbl(…)`),
and a `fn(…)` value carries none, so it is not one. Pass a free fn,
or call the method where the value is needed

A fallible(E) fn is not a value either, a program’s own, an imported seed’s (lib::parse) or the stdlib’s: its ABI returns the failure beside the value, and a fn(…) -> T value’s call reads a plain result, so there is no error channel to carry it through. Its name read as a value is a type error at the name that names a wrapper handling the error:

main.hl:4:27: type error: `parse` is `fallible(Oops)`, and a fn value
has no error channel: a call through it could not address the
failure. Wrap it in a fn that handles the error, `fn parse_or(a0:
String) -> Int { return parse(a0) or 0; }`, and pass that

A fn returning a locus is a value only when it builds every instance it returns — a fresh factory (spec/semantics.md § Dissolve timing rules): a call through a fn value hands its caller a fresh instance to own (a binding’s or a holder’s, else the frame’s temporary), so a fn that may hand back one it was given (fn id(w: W) -> W { return w; }) is a type error at its name:

main.hl:4:42: type error: `id` may hand back a `W` it did not build (one
it was given, or one another binding keeps), and a call through a fn
value hands its caller a fresh `W` to own: only a fn that builds every
`W` it returns may be taken as a value. Pass a fn that builds one, or
call `id` directly

A fn that hands back what a parameter of a fn type builds (fn via(f: fn() -> R) -> R { return f(); }) builds what it returns.

So every fn value returning a locus is a fresh factory, wherever it came from — a fn’s name, a call that returns one (let f = pick(); with fn pick() -> fn() -> W), an if, a loop variable over an array of them, a tuple pattern’s name — and a call through one is owned as a factory call is: by the binding it is bound to, by the field or the caller it is handed to, else by the frame, and a discarded one at the statement.

A fn handing back a tuple or an array with locus parts is a value under the same rule: only when it builds every locus part it returns (fn mk2() -> (W, Int) { return (W { }, 1); }), or hands back what a fn value it was handed builds, or a call of a fn that is one itself (fn mk3() -> (W, Int) { return mk2(); }, through any chain of such fns). The rule holds wherever a fn’s name is read as a value. A record’s field cannot hold such a fn value at all: a type holds no locus, not even in a fn type’s signature, so type R { f: fn() -> W = mkw; } is refused at fn() -> W, and so is a field or a variant typed by an alias of such a fn type (type Maker = fn() -> W;), through any chain of aliases.

A std:: fn is a value when the stdlib writes it in Hale: its body is merged into the program under its rename, so apply(std::url::encode, s) passes that fn as apply(dbl, 1) passes dbl, typed by its signature (a fallible one, std::hex::decode, is refused as above). A builtin the stdlib answers at a call (std::math::abs, std::str::upper) has no fn behind it, and its path in any position but a call’s callee is a type error at the path that names a wrapper:

main.hl:2:27: type error: `std::str::upper` is not a fn value: the
stdlib answers it at a call, and there is no fn behind it to pass.
Wrap it in a fn of your own, `fn upper_of(a0: String) -> String {
return std::str::upper(a0); }`, and pass that

A call whose callee is a bare identifier must name something: a local binding (a fn pointer), a free fn, a generic fn, or one of the builtins the compiler answers itself. That set is exactly:

group names
length and rendering len, to_string
the numeric casts Int, Float
the printers print, println, eprint, eprintln
the numeric trio abs, min, max
the string predicates starts_with, contains
the bounded intrinsics push, at, set, count, clear, truncate
accumulators, inside a closure assertion count, mean
the explicit-epoch closure surface check_closures

(sum(x) and prod(x) are accumulator vocabulary too, but the parser gives them their own syntax rather than a call, so they are never a bare callee. __fmt, the desugaring of f"{x:spec}", is the compiler’s own and is not written by hand.)

In a whole program — every import resolved, which is every command’s: hale check on a seed (<directory>, what the organization’s gate runs) or on one file, every command that compiles (hale build / hale run / hale test / hale replay compile exactly what they bundle) and hale lsp — any other bare callee is a type error — call to X: no free fn, generic fn or fn-pointer binding with that name is in scope, with a did-you-mean over the program’s fns, or, when a stdlib fn has exactly that name, its path (substring → std::str::substring: a stdlib fn is called by its path, GH #1948). A std:: type path that names nothing (std::str::Builder) likewise names the stdlib type meant: a tabled move (std::bytes::BytesBuilder, which builds text too) or the one stdlib type of that name in another namespace. The rule holds wherever the call stands: a statement, an operand, a condition, a fn or method body, a lifecycle hook, a bus handler, a params default, a const initializer. Only a partial program a library caller assembles (a styleguide snippet, a test harness’s fragment) keeps the permissive reading (dna/FRICTION.md F.18).

A binding declared as a fn value shadows a top-level fn, or a builtin (len, min, a bounded intrinsic, a printer), of the same name in a call, as it does wherever else the name is read. A binding is declared as a fn value when its declaration says so: a parameter or a let written with a fn(..) type, a let (or a tuple let‘s part) of a fn’s name or of another such binding, a for over an array literal of fns’ names, a match pattern’s binding of a variant’s value whose declared type is a fn(..) type (Op::Use(f) with Use(fn(Int) -> Int)). A .Use(f) pattern (F.58) binds f as E::Use(f) does, E the matched value’s enum, so a call of f calls the binding exactly where the spelled pattern’s would: where E’s Use holds a fn(..). Where the match shows its enum (an arm spelling it, the matched value’s binding declared as it, or one enum alone declaring Use), the shadowing is decided with the rest of this rule; elsewhere (a field, a call, an element matched, and several enums declaring Use) the check, which resolves the pattern, decides it, and the program is read with the call through the binding written in. So fn apply(f: fn(Int) -> Int, x: Int) -> Int { return f(x); } beside a fn f calls the parameter, and { let helper = zero; helper() } calls zero.

A bare callee no such binding shadows names the fn or the builtin. A binding of a known type that is no fn leaves it so (let max = 10; max(1, 2) calls the builtin, max still reads 10). A binding whose declaration does not show it to be a fn value, while its type is one or is one the check cannot name (a tuple pattern’s part, (helper, n) -> over a (fn() -> Int, Int); a value read from a field or a call), would read as the callee and is not: the check refuses the call, and the binding is given its type, or renamed. A call through a value that is no fn (let x = 3; x(2)) is refused at the callee.

A call through a fn value (a local, a parameter, or a locus’s or a record’s field of a fn(..) type) is held to the value’s type as a direct call is held to the fn’s parameters: each argument flows into its parameter’s type, an Int widening to a Float parameter as at a direct call, and the count is the type’s. A fn type has no defaults, so every argument is passed; a short call is refused at the callee (until 2026-11-15 the check passed it and the build refused it with no place):

main.hl:7:13: type error: `add2` is a fn value of type `fn(Int, Int) ->
Int`, which takes 2 arguments, got 1: a fn type has no defaults, so
every argument is passed

A call the compiler writes into the user’s scope (an f-string’s to_string and __fmt, a from_json’s parser) is the compiler’s, whatever binding of the name is in scope. A qualified callee (lib::helper()) names the declaration. The check and the build read every call one way: the desugar sequence calls a shadowing binding as a value before either sees the program.

hale check <file> loads that file and what its own imports reach, never the other files of its directory — exactly what hale build <file> loads — so a fn only a sibling file defines is unbound in the program both commands see, and both refuse the call. Until 2026-10-11 the file target kept a permissive reading for a sibling’s fn, so hale check f.hl accepted a call to a fn nobody wrote that hale build f.hl refused. A multi-file seed is checked as the seed: hale check <directory>. When a file target is refused for a name nothing binds and other .hl files sit beside it, the check says so after its diagnostics (not under --json, whose stream carries the records alone):

main.hl:1:21: type error: call to `sib_helper`: no free fn, generic fn or fn-pointer binding with that name is in scope
note: `main.hl` was checked alone, as `hale build` builds it; the 1 other .hl file(s) beside it are not loaded, so a name only they declare is unbound here — `hale check .` checks the whole seed

The rule was on for the seed check alone until GH #911 B1, so the build path let the call through to codegen, which refused it as unsupported in codegen v0: call to X: … — from a layer below the one that had just approved the program, with no file, line or caret, and a did-you-mean drawn from compiler-internal symbols. The two layers gave two answers to one question; they now give the located one.

The list is a contract in both directions, and neither is optional.

A name the compiler answers must be exempt from the rule. A builtin the rule does not know about turns the admission gate into a refusal of correct code — hale check red, hale run fine — which is strictly worse than the late diagnostic the rule exists to replace (GH #779).

A name the rule exempts must be one the compiler answers. An exemption for a name nothing lowers is the divergence the rule was written to remove, moved inside the rule: hale check accepts the call, and hale build refuses it at lowering, without a source location. The list is therefore exactly the set above and carries no aspirational entries — a name is on it when codegen dispatches it, not when it looks like it should (GH #800). The compiler tests both directions over its whole program corpus rather than trusting the list.

The value builtins have types, and the checker and the compiler read them from one signature table:

call operands type
len(x) a String or Bytes (or a view of either), a fixed-size array Int
to_string(x) a printable value String
Int(x) / Float(x) an Int or a Float Int / Float
abs(x), min(a, b), max(a, b) Int, Float, Duration or Decimal, one type throughout; min / max also two values of one quantity, or of two points of one origin, at one denomination (spec/units.md § The algebra) the operands’ type
starts_with(s, p), contains(s, p) two Strings Bool

A call over operands outside its row is typed as unknown: the checker names no type for it, and the compiler refuses it where it lowers it. So first(len(s)) instantiates first<Int>, and let n: String = len(s) is a type error at the let. Two operands outside len’s row are refused at the check itself, each pointing at the spelling that holds: a bounded[T; N] (its live count is count(x), § bounded[T; N]) and a form locus (its length is the form’s synthesized len() method: “`len` does not apply to a `V`: a `@form(vec)`’s length is `v.len()`”, forms.md § Synthesized methods), where the build refused the form case with no file or line until 2026-11-06. Every other operand of a known type outside len’s row (an Int, a tuple, an enum, a record) is refused at the call (“`len` does not apply to a value of type `(Int, Int)`: it is the length of a `String`, a `Bytes`, a view of either, or a fixed-size array”), and so is an Int(…) or Float(…) operand outside theirs (§ Explicit numeric conversions); the build refused each with no rule of its own (GH #1942).

The same rule holds in value position. A bare identifier must name something in scope: a local binding, a fn param, a match-arm binder, the implicit err of an or handler, a chain’s it / idx, a top-level const, or a top-level declaration (fn, locus, type, interface; a topic resolves and is then refused by its own rule — it addresses a channel, it is not a value). In a whole program — every import resolved, which is hale check on a seed or a file, every build (hale build / hale run / hale test compile exactly what they bundle) and hale lsp, which loads the whole seed as hale check <dir> does, imports followed, and typechecks it only once every member has read and parsed — any other bare identifier is a type error at its own span: unknown identifier X: no binding, param, const or declaration with that name is in scope, with a did-you-mean over the locals in scope and then the program’s top-level names.

Before this, an identifier that bound nothing typed as Unknown, which is permissive everywhere, so a one-character typo passed check and verify and failed in the backend as unknown identifier with no source location.

One file of a multi-file seed, checked alone (hale check <file>), is held to the rule as its build is: a const only a sibling file declares is unbound in the program the file target loads, and the check refuses the read with the note above. (It kept a permissive reading until 2026-10-11, which hale build <file> never had.)

A name a block of the same body bound and released — if take { let x = 1; } return x; — is the block’s (§ “Dissolve timing rules” in spec/semantics.md), so the refusal says so: unknown identifier x: … it was bound in a block that has ended, and a block's binding is the block's (GH #1139).

A bare unknown CALLEE reports the call diagnostic above and not this one — one mistake, one message (GH #721).

And the same rule holds in TYPE position. A bare name written where a type is expected must name a declaration: a primitive, a type (struct, enum or alias), a locus, an interface, a generic parameter of the declaration being checked, or one of the types the compiler synthesizes for its own channels (IoError, ParseError, CryptoError, IndexError, KeyError, EmptyError, CapacityError, BusUnmatchedKey, ClosureViolation). A synthesized type names the same record in a signature as in a body: a parameter typed ParseError takes a ParseError, and an argument of another type is refused at the call (GH #2005; the signature had read it as unknown, so the check passed default_port("x") and an or’s String err, and the build refused them). In a whole program — the same set of callers as above — any other bare name is a type error at its own span:

main.hl:1:16: type error: unknown type `int`: no type, enum, locus,
interface or alias with that name is declared — did you mean `Int`?

The rule holds in every annotation position: a fn parameter and return, a fallible(E) payload, a struct field, an enum variant’s payload, an alias target, a const ascription, a locus params field, a capacity cell type, a lifecycle / mode / on_failure parameter, and a let ascription — including inside the compound forms, so the name in [Row; 4], (Int, Row), bounded[Row; 8], fn(Row) -> Row and Rich<Row> is checked as well.

Before this, an unresolvable bare type name resolved to Unknown, which is permissive everywhere, so fn helper() -> int typechecked and then failed in the backend as unknown type name 'int' in signature — no location, and the annotation had silenced every check that would have used it (GH #877).

A QUALIFIED name (lib::Thing, std::text::Sink) is NOT subject to this rule. It resolves against the bundle’s import-rename table, which only a caller that merged the imported seeds has, so a tool holding one seed without them keeps the permissive reading for paths (GH #803 / #833). One file of a multi-file seed, checked alone, does not: it loads what its build loads, so a type only a sibling declares is refused by both.

For two contracts C1 and C2, C1 ⊆ C2 iff every entry in C1 has a matching (compatible) entry in C2. This is used for:

  • Parent-child compatibility: parent’s consume ⊆ child’s expose.
  • Locus-type substitutability: when a child locus type is expected, any locus type with a compatible expose-surface may substitute.

Per F.6 / F.11 / memory.md: cross-locus references at the type level are limited to the contract’s typed surface. Specifically:

  • A reference to a coordinatee accessible only via self.children[i].x where x is in the contract.
  • Sibling references: not typeable. No syntax exists for reaching from one sibling to another; if attempted via manual pointer construction, the compiler rejects on region-lifetime grounds.
  • Grandparent references from a child: not typeable. Failure flows through bubble; intent flows through the parent.

This makes the framework’s vertical-only commitment a type-system invariant, not just a convention.

A locus’s methods may be invoked only on the OS thread that owns the locus’s placement’s pool. Cross-pool direct calls are typecheck errors; cross-pool coordination goes through the bus.

The invariant is enforced via a static call-graph walk over the placement table (the placement family: one row per static instance, seeded from the main locus’s placement { } entries):

  1. Each main-locus params field has a pool — explicit (placement { field: cooperative(pool = X); } or placement { field: pinned; }) or default (cooperative(pool = main)).

  2. Each nested locus inherits its containing tower’s pool (see spec/semantics.md § “Nested instantiation”). Methods on a nested locus run on the parent’s pool’s thread.

  3. For a method-call expression self.field.foo(args), the caller is each instance of the enclosing locus, on its own pool, and the receiver’s pool is the pool of that instance’s field instance: the enclosing locus’s own placement { } entry for field if it names one (e.g. a db: pinned field on the main locus), otherwise the field co-locates with its owner (the caller’s pool). A field that holds an instance built elsewhere (App { w: held }) runs in its holder’s pool whatever an entry names for it; such an entry is refused (GH #890). The pool is a property of the instance, not the field’s type — the same locus type used as a field in two loci on two pools is two independent instances, one per owner, each single-pool. A field is a receiver however its type is written: a single name, a qualified path (std::log::Logger), an alias, or a contract the field’s literal implements, named in the diagnostic by the locus it realizes. An enclosing locus the table holds no static instance of (one built only inside a method body, or one held through a parameter) is not judged: its pool is unknown, never assumed to be main.

  4. If the receiver instance’s pool differs from the caller’s pool, the call is rejected with a diagnostic naming both pools and pointing at the placement { } entries that picked them.

    The receiver is the field instance however the call reaches it (GH #1561): below the field (self.h.w.m(), self.h.ws[i].m() — a nested instance, an element included, runs in its holder’s pool), through a local bound to it (let w = self.w; w.m()) or a for over its elements. The check is a dataflow over the body: each local carries what it may be (a cross-pool instance) and what it may hold (a tuple, array or record around one, a fresh locus literal whose params do), joined where control flow merges, iterated to a fixpoint over a loop (its condition included, at every iteration), with each block’s lets in a scope of their own (a shadowed binding keeps its own rebinds) and a block’s, if’s or match‘s value taken from its tail before its locals go out of scope; a part written (ws[0] = self.b) joins into its container, a field of self any member stores a handle into may be that handle wherever it is read, and an operand or fallback that may be skipped (&&, ||, or) is joined with the state that skipped it. A call carries its callee’s writes too: a helper that writes one argument into a part of another (fn install(ws: [W; 2], w: W) { ws[0] = w; }), or a method that writes an argument into its own field, leaves the caller’s container or field holding that argument’s handle, and so does a method that writes one of its own fields into an argument (that field of the receiver, per instance). A bounded-list push or set stores its value into the list (no form cell can be a locus); a stdlib fn may write an argument into another only when the other’s declared type can hold it; a call through a fn value, or one the check cannot see into, may write any argument into any other; a serve site (api::serve) writes none, its receivers being reached through the bus. A locus literal is one instance however many bindings copy its handle: what is written into it through one (let alias = h; alias.ws[0] = self.b;) is read through every other (h.ws[0]), and its params’ values are held by field. A method that stores into, or calls a method on, a locus one of its own fields holds (fn poke() { self.ws[0].name = s; }) is judged, on a receiver that is no field of self (a literal, a local or a parameter bound to one), on what that receiver’s field may hold: H { ws: [self.b, self.a] }.poke() is the store into self.b itself, as is the same call on a field of self a member stored that literal into, or through a local or helper inside the method (let w = self.ws[0]; w.name = s;, put(self.ws[0])); a method of a receiver whose locus type the check cannot tell (hs[0].poke()) is judged as every method of that name. A locus a helper builds and returns is one instance built at the call, holding what the helper’s held (let h = make(); let alias = h; share it), and one it was handed is still that instance. A callee the check has not yet summarized does nothing until it is, so the order fns are declared in never changes a verdict. A value whose type can hold no locus handle (a record of data, a String) carries none: reading one copies it. A value comes from a field of self (or below one), another local, a part of one (p.0, ws[1], n.w), a literal holding one, or a call: a fn or method by what its body may return (a parameter or a part of one, a field of self, or a value holding one — summarized per body, transitively; a fresh record of its own carries nothing, a fresh locus is the instance built at the call), a call through a fn value declared to return a locus type by any instance of that type (one on another pool is enough), and a stdlib call by its declared result, which carries an argument’s handle only when it can be or hold that argument’s type, a generic result included. (A method may not return a locus itself.) — and through a free fn handed it that calls a method on its parameter (fn poke(w: W) { w.m(); }, poke(self.w)), directly or by handing the parameter on to such a fn (by name, a fixpoint over the program’s free fns).

    A store into a field of the receiver instance is that locus’s own work, as a method call on it is (§ A store into a locus’s field is the locus’s own), and is rejected the same way when the pools differ, reached the same ways: a store down self.field (self.w.name = s, self.h.ws[i].name = s); a store through a local bound to self.field (let w = self.w; w.name = s;); and a call of a free fn that stores into a field of the parameter it is handed self.field at (put(self.w, s) with fn put(w: W, s: String) { w.name = s; }). The last includes a fn that hands that parameter on to such a fn, transitively. The diagnostic names the locus, both pools and the store, and suggests a method of that locus, reached through the bus. GH #1561: such a store copies the value into the receiver’s arena and retires what it replaces, which only the receiver’s own thread may do. A store whose slot is an inline scalar (a number, a Bool, a Time or Duration, a unit scalar, a payload-free enum, read from the declarations) is one plain store with no arena work, and is not rejected, as a cross-pool field read is not.

    Not followed, known: what a handler the runtime calls through a function pointer does (an std::http::Server handler, a serve site’s receivers: the site is the exposure it builds, and the handler runs on the server’s pool); a stdlib locus’s own methods, which are not summarized (a call on one may move any argument into any other and into the receiver, but what it stores into or calls on a locus it holds is not judged); the parameter effects of a method on a receiver whose locus type the check cannot tell; and a call through an interface. A locus’s params defaults are walked only for the hand-over rule below. Where the check cannot tell instances apart it takes them as one: every instance one literal (or one call of a helper that builds one) produces, and every free fn of one name, so it may refuse a store into an instance that never holds the handle another one does.

    One instance is never shared across pools (GH #1566). A locus that holds an instance in a field reaches it as its own, on its own thread, so handing it an instance that runs on another pool makes one instance two threads write. Such a hand-over is refused where it is made: a locus literal’s param, a store into a locus’s field (or an element or part below one), or a call of a helper that does either with an argument — whenever the value may be an existing instance (a field of another instance, or a value reached from one, through locals, blocks, parameters, returns and aggregates) that runs on another pool than the locus receiving it. A literal or store in a member runs on the member’s pool; one in a params default builds for the field it fills, so srv: std::http::Server = std::http::Server { .., handler: Routes { w: self.a } }, with srv placed on io and a on main, is refused at self.a — and so are Routes { w: { let x = self.a; x } }, mk(self.a) with fn mk(w: W) -> Routes { return Routes { w: w }; }, and the same with a local in mk:

    cross-pool alias: `W` (`self.a`) runs on `cooperative(pool = main)`; `mk(…)` hands it to `Routes`, which runs on `cooperative(pool = io)`, shares one instance across pools — build it on that side, or reach it through a method on the bus.

    A stdlib locus literal (std::http::Server { handler: … }) receives its params the same way, and a field of self the placement table places no instance for (a tuple or an array of loci, a field of interface type) runs where its owner does: handler: self.pr.0, with pr: (Routes, W) on main and the server on io, is refused. An instance the code builds itself and hands over (Routes { w: W { } }, a helper that builds and returns one) is moved, not shared, and is accepted; so is a hand-over within one pool. A locus whose form synchronizes access from another domain, and a stdlib locus (a metrics registry, a router), may be shared: their own synchronization carries the contract, and a method call on one from the wrong pool is still refused as above.

    The rule is checked statically where the walk follows the handle, and enforced at run time at every remaining site (GH #1566, spec/runtime.md § Cross-pool backstop): every instance records the domain it was built on, and a store into a locus’s field from outside its methods (not an inline scalar slot) or a method call on a locus reached any way but down self (through an interface, on the locus behind it) compares the receiver’s domain with the running code’s. A mismatch is a violation: the program prints the site, the store (or the method call, cross-pool method call with the method) and both pools, and exits 1, before the store or the call touches the other pool’s locus:

    main.hl:8:9: violation: cross-pool store into `W.name` from pool `io`; this `W` runs on pool `main`: reach it through a method on the bus

    An instance is on the domain it was built on until a locus first holds it in a field (a literal’s param, an element of an array param, a store, a field of interface type): an instance no locus held yet — one the code built and handed over through locals and parameters, Web built in fn main and handed through helpers to an io-placed server’s handler — becomes that holder’s and moves onto the domain it runs on, with everything it is in turn the first holder of (a provider composed from locals moves with the service it holds). An instance a locus already holds is shared by a later holder, not moved: it keeps its domain, so whichever side is not its owner is caught (the hand-over the check cannot follow, a builder called through a fn value, fails at the holder’s first store into it). Down self, a receiver is checked when the path goes through a field filled with anything but a value the literal or store builds right there. Hale does not refuse a use of a local after the hand-over, so a builder that kept it and reaches the instance from its own domain afterwards is caught at run time too. A receiver whose form synchronizes access from another domain, and a local bound to a locus literal the running code built (never rebound, never handed over), are not checked; a locus’s drain() and dissolve() run as its own domain wherever the runtime runs them, and an on_failure handler reaches its failed child, and the subtree the child owns, on the child’s domain — not any other instance there. A violation found inside the stdlib, which has no location of its own, is reported at the program’s last call into a stdlib locus on that thread.

    Two exemptions are by design. What a bindings { } entry builds (an adapter, a transport, a codec) belongs to no one domain: the runtime calls an adapter’s send from every publishing thread through a function pointer, and the adapter’s own synchronization carries that contract. And a stdlib locus handed a value of self at its literal (an exposure its transport, a server its handler) is driven from the pool its machinery runs on: the stdlib’s own synchronization covers it, so such a field is not checked down self.

  5. Bus sends (Topic <- v; / "subj" <- v;) are unrestricted — the runtime’s cross-thread dispatch (m28b condvar+memcpy) handles the boundary safely.

The invariant is the substrate enforcement that makes M:N cooperative pools safe. Without it, multi-pool deployments would silently race on locus arenas (unsynchronized bump allocators by design). The typecheck happens once per main locus (the placement-bearing locus is unique per binary), so the rule applies at binary compile time rather than at every library typecheck.

Interaction with LocusRef borrows. A locus param of type LocusRef(L) carries a borrow of an L — but the borrow’s pool is the locus’s own placement, not the borrower’s placement. So self.db.query(...) where self.db: DB and the DB instance is on pool db_pool is a cross-pool call from any non-db_pool thread, and routed through the bus. This is the “vertical-only flow” rule generalized to cooperative pools: cross-pool access is the same shape as sibling access — bus only.

Interaction with builtins / stdlib. Free functions and stdlib path-calls (std::io::fs::read_file, std::str::*, etc.) are pool-neutral — they run on whichever thread calls them. Their arena routing through lotus_current_caller_arena TLS handles the per-thread isolation. The single-threaded- method invariant applies only to locus member functions, which are what carry per-locus arena state.

Interaction with @form(...) loci. A locus declared with a @form(...) annotation (@form(hashmap), @form(vec), @form(ring_buffer)) is single-pool by default — its methods participate in the same single- threaded-method invariant as any other locus. Plain @form(...) cells have no runtime synchronization; concurrent writers from different pools corrupt the underlying structure.

Cross-pool access is opt-in via the sync = kwarg on the form annotation:

Annotation Discipline Trade-off
@form(hashmap) single-pool only densest layout, no sync overhead, cross-pool calls rejected
@form(hashmap, sync = serialized) per-map mutex (F.32-1α) correct cross-pool; throughput bounded by lock contention
@form(hashmap, sync = striped) cell-level CAS + per-map rwlock for grow + cache-padded cells (F.32-1β2-v2) parallel writers; grow path serializes; rwlock overhead can outweigh parallelism on cheap-payload workloads
@form(hashmap, sync = lockfree) (optional cap = N hint) cell-level CAS, no rwlock or mutex on the steady-state path; remove via tombstones + lazy grow with a brief migration stall (F.32-1γ-v2) highest measured throughput on the false-sharing bench

When a locus carries a recognized sync discipline, cross- pool method calls into it are accepted without diagnostic — the substrate’s chosen discipline carries the safety contract. Plain @form(...) (no sync kwarg) gets the same cross-pool diagnostic as any other locus, extended with an upgrade-path hint naming the sync kwargs.

Because a form field’s pool is its instance’s (rule 3 above), two loci that each hold their own @form field of the same type on different pools are two separate, single-threaded structures — each accessed only by its owner’s pool. Neither is a cross-pool access, so neither is flagged, and neither needs a sync discipline (there is no sharing to synchronize). The diagnostic fires only on a genuine cross-pool access — reaching one instance from a pool other than the one it lives on, e.g. a form field explicitly placed off its owner. (This is why two same-type form instances on two pools do not require byte-identical twin types.)

Concrete shape: a Registry @form(hashmap, sync = striped) of Counter indexed_by name shared across producer pools (gateway loci incrementing counters) and a consumer pool (MetricsEndpoint rendering Prometheus text) typechecks clean. Without the sync = striped, every cross-pool self.registry.counter(...) would be rejected.

Non-form receiver loci have no sync discipline available; cross-pool coordination must go through the bus.

Inference. F.32-1∞ adds a closed-world inference pass that picks a sync default per form-bearing locus type from the pool-propagation graph. The explicit annotation always overrides; the inferred pick is shown via a compile-time diagnostic at the decl site. See notes/f32-cache-aware-delivery-plan.md § F.32-1∞.

History. Commit 3ec6391 (2026-05-24, first cut) admitted any @form(...) locus into the cross-pool-safe set unconditionally, on the strength of a not-yet-shipped “form ABI serializes” claim. Bench-prep for F.32-1 surfaced that the runtime had no synchronization on the form paths; F.32-0 (this section’s current state) scopes the exemption to explicit opt-in via sync = X. See notes/f32-cache-aware-delivery-plan.md § F.32-0.

A closure name { left ~~ right within tolerance; ... } declaration types as:

  • left and right must be expressions of compatible numeric types (integer or numeric).
  • tolerance must be a non-negative numeric expression.
  • The compiler verifies left/right resolve in the closure’s scope (which is the locus’s scope; self.x is permitted, member fns may be called).
  • For epoch tick / epoch duration(d) / epoch dissolve / epoch birth / epoch explicit, the runtime evaluates the closure at the appropriate event boundary.

A closure failure at evaluation produces a typed ClosureViolation event (per F.9), not a generic error.

A function declared -> T fallible(E) produces a value of type T fallible(E) at every call site. This type cannot be used where a plain T is expected — the caller MUST address the error before the value is consumable. See spec/design-rationale.md for the design rationale.

Declaration sites are restricted by the two-channel rule (see spec/semantics.md § “Fallible call semantics” § “Where each channel lives”). fallible(E) may be declared on:

  • Free fns.
  • Stdlib-synthesized methods over @form(...) containers (@form(vec).get / .pop, @form(hashmap).get / .remove / .key_at / .entry_at, @form(ring_buffer).pop).
  • User-declared fn member fns on a locus (open-question #24, shipped 2026-05-25). Heap-bearing success and err payload types are supported via the same TLS caller-arena snapshot non-fallible heap-returning locus methods use.
  • Interface method signatures (GH #732) — see § “Interface types (F.20)” for which methods satisfy one.

fallible(E) is rejected on substrate-facing surfaces that have no caller frame to address the error channel:

  • Lifecycle methods (birth / run / accept / drain / dissolve / on_failure). Physically rejected at the AST level — LifecycleDecl doesn’t carry a fallible field.
  • Closure assertions. Substrate evaluates the assertion at the epoch boundary; no caller frame exists in the expression.
  • Bus-subscribed handlers. A fn that’s declared fallible(E) may not also be referenced by a bus subscribe ... as <fn> declaration. Bus dispatch has no return path. Rejected at the subscribe site, not the fn decl (one fn may be referenced by zero subscriptions; the subscription is what fails to typecheck). A subscribed handler MAY declare a return type (GH #1106): bus dispatch ignores the value. A reply to a caller is a served rpc row’s response (spec/api.md § Surfaces and their rows), not a bus handler’s return.

The narrowing from “no fallible on locus methods” to “substrate-facing surfaces only” preserves the two-channel separation (structural failures still flow vertically via closure violations + on_failure) while removing the friction that made devs extract free fns just to get a value- error channel back. The typechecker emits the diagnostic at the offending site (locus member decl for lifecycle / mode; subscribe site for bus-handler-fallible conflict).

The checker represents fallible returns as a wrapper around the underlying success type:

Source Inferred type
fn f() -> T fallible(E) f() has type Ty::Fallible { success: T, payload: E }
or on fallible unwraps to T

Only an or addresses a Ty::Fallible: it must be unwrapped at the immediate call site, as the operand of an or (or an or’s handler, below). Anywhere else the call is bare, and the bare_fallible law reports it with one error naming the callee and its payload (spec/semantics.md § “A bare fallible call is an error”), at:

  • let v = f(); with f fallible
  • let v: T = f(); with f fallible (typed binding)
  • f(); as an expression statement
  • g(f()) — fallible passed as an argument
  • match f() { .. } — a match does not handle it
  • operand, assignment, return, condition positions

The checker types a bare fallible value as its success type T, so the position reports no type mismatch beside the law’s error.

<expr> or raise : Propagate the error one frame up the static call stack. Evaluates the inner; on FallibleErr payload, re-enters the fallible-return shape of the enclosing fallible(E) fn (the error climbs the call stack until a frame addresses it). The value-error channel is value-level and orthogonal to the closure-violation channel; the bubble / on_failure machinery is not entered by default. (An application may later promote a value error to a closure violation explicitly; no such syntax exists in v1.) On success, passes the inner value through. The resulting expression’s type is the success type T.

The error handed on is the enclosing fn’s E: the call’s own when it is that type, else converted, as a member of E when E is a set holding it, or by the one @raise fn from its type to E (spec/semantics.md § “Converting a raised error”). An error nothing converts is refused at the or raise.

Past every enclosing fallible(E) frame — at the implicit main locus’s root boundary — the runtime panics via lotus_root_panic. See spec/semantics.md § “Process exit” for the boundary semantics.

<expr> or <fallback> : Substitute a fallback value of type T. On failure, evaluates the fallback expression with err implicitly bound to the payload (typed as E). On success, passes through. Fallback type must be assignable to T. The fallback may itself be a call (or handler(err)), making err a regular expression-position binding inside the fallback.

Fallible handlers: the handler may itself be fallible(E2). Its success value substitutes; its FAILURE propagates through the ENCLOSING fn’s error path — implicit or raise, sugar for the already-legal nested spelling call() or (handler(err) or raise). E2 must be the enclosing fn’s declared payload or one that implicit or raise converts from, as a written one does (“handler’s failure has nowhere to go” / “propagated payload must match” otherwise). The implicit or raise applies where lowering supports it, a limitation to lift rather than a rule: a fn the program declares (not a generic one), an imported or bundled stdlib fn written as Hale, and a locus member fn called on self, a local or a field of self. Any other fallible handler (a stdlib path-call, a generic fn, an interface’s method, an @form-synthesized or an array’s method) is refused with the explicit nested spelling to write instead. In statement position the substituted value is discarded, so the handler’s success type needn’t match the call’s.

The fallback may be a { block } — or { … }, with err in scope — for multi-statement recovery. Two cases:

  • A block that always diverges (return / fail on every path) produces no substitute value, so it imposes no constraint on T and is accepted for any success type — let s = read_file(p) or { return "fallback"; }; where the fallible’s success type is String, Bytes, a struct, etc. (It disposes like or raise: the err branch is closed and only the success value reaches the continuation.)
  • A non-diverging block substitutes its tail expression as the fallback value, whose type must be assignable to T: let s = read_file(p) or { log(err); "default" };.

On a Unit-success fallible (() fallible(E), e.g. std::io::fs::write_file), or { block } runs the block for effect — including in statement position: write_file(p, s) or { println("failed"); }; — the same as or raise / or discard there.

A statement or on a value-bearing fallible runs its substitute the same way, for its effect: parse(s) or { log(err); };, parse(s) or note(err); with a handler of any type, or parse(s) or 0;. (Until 2026-10-13 the build refused a block with no tail and a handler of another type there, which the check admitted.)

The value of an or whose call succeeds with () is no value: let full = push(self.marks, t) or { }; is refused at the expression, as every ()-typed expression in a value position is (spec/semantics.md § “Expressions with no value”). Write the call as a statement.

The or operator is right-associative: a() or b() or raise parses as a() or (b() or raise), so each level disposes one fallible in turn until a non-fallible value remains.

ClosureViolation, the error of a violating fn (F.42)

Section titled “ClosureViolation, the error of a violating fn (F.42)”

A value-returning fn or locus method whose body may violate (spec/semantics.md § “A value-returning method that may violate is fallible”: a violate statement in its own body, or a call to a value-returning fn that may violate and is not fallible) is declared -> T fallible(ClosureViolation). The checker refuses it otherwise, at the fn’s name: “`P.take` returns a value and may violate (`violate exhausted`): declare it `fallible(ClosureViolation)`; its callers then say what happens when the locus fails”. A fn has one error type, so one that may violate declared fallible(E) with any other E is refused too. Lifecycle bodies, bus handlers and fn main are exempt; a fn returning nothing that may violate is warned about rather than refused.

The violation is the call’s failure. The caller’s or runs, and the err an or handler(err), an or { … } or an or fail sees is typed ClosureViolation (err.locus, err.closure, err.diff), the record the owner’s on_failure received; at a stdlib method’s call (BytesBuilder.snapshot and finish, the stdlib’s two) as at a program’s own.

fail <expr>; is only valid inside a fallible fn body. It evaluates <expr>, requires the result type to match the fn’s declared payload type E (or to be a member of E, a set), and exits via the error path (the caller sees a FallibleErr value).

The payload E is an ordinary type expression — usually a small user-defined record (type ParseError { ... }) or a stdlib- synthesized type. The runtime / typechecker does NOT impose a common base — there is no Error trait, no impl Error for ParseError. Failure is a single anonymous fact; the payload is just a value tagged onto the failure for diagnostic purposes.

Across an API boundary the payload is a contract: a fallible(E) handler that a surface row names (spec/api.md § Surfaces and their rows) has E as the row’s error type, hashed into the surface’s digest, described as the member’s error schema and carried to the caller as the handler error outcome (422 over HTTP, {"ok": false, "error": E} over the Unix socket; spec/api.md § Outcomes), encoded by the exposure’s codec like the response.

The resolver injects four fallible-payload types into the top scope so user code can name them in fallible(...) markers and or substitute clauses. All are idempotent — a user-declared type with the same name wins.

Winning means standing in for the builtin wherever lowering builds one under that name, and the stdlib’s own code is merged into every program: its parsers reach ParseError, std::crypto reaches CryptoError, its bounded pushes CapacityError, its closures ClosureViolation, its @form loci IndexError and KeyError, in every program whether or not the program calls them. So a program’s type of one of those names that lacks a field of the builtin’s shape (by name and primitive type) is a type error at its declaration:

main.hl:1:1: type error: user-declared `type ParseError` shadows the
stdlib's `ParseError` but is missing the expected `kind: String`
field (the stdlib's own code, merged into every program, and lowering
build `ParseError` under that name on failure). Either match the
stdlib shape, rename your type (e.g. `MyParseError`), or use
`std::str::ParseError` qualified where you need the stdlib's shape.

EmptyError and the other builtins the stdlib does not reach are refused only in a program that reaches them itself (a @form(heap), a std:: call failing with one).

Trigger Type Fields
@form(vec) IndexError kind: String, index: Int, len: Int
@form(hashmap) KeyError kind: String (also surfaces IndexError on key_at / entry_at — those are index-based, added 2026-05-16)
@form(ring_buffer), @form(heap) EmptyError kind: String
std::io::fs::* / std::io::tcp::* IoError kind: String, errno: Int, path: String, detail: String

The IoError payload is the unified shape for the fallible I/O surface — see spec/stdlib.md § “IoError” for the errno → kind tag taxonomy.

role NAME; at top level declares a role: authorization vocabulary, the way group declares claim vocabulary and effect declares an effect class. A role is a name the deployment maps to principals; the program never says who holds it. role NAME includes A, B; is the hierarchy: whoever holds NAME holds A and B, and whatever they include, transitively. Composition is grant-only and union-only (the constitutions rule): includes can only widen what a holder may do, so a cycle says nothing and is an error, and a name declared twice is an error rather than a merge. A role an includes names must be declared; no role is implicit (owner is a role only a program that declares it has). Role names are deployment vocabulary (the keys of [environments.<env>.roles], the word a refusal names) and are never mangled: an imported seed’s role x; and the entrypoint’s are one x, and declaring it in both is the duplicate error.

A role another seed declares may be named through the import alias, lib::reader, wherever a role is named: a requires: [...] list (a surface row’s, an @rpc attribute’s, a hub binding’s) and an includes. The path collapses to the role’s own name when the seed the alias imports declares that role, so lib::reader and the bare reader are one role and a description, a refusal and the environment’s role table all say reader. Roles are their own namespace: a library that declares role reader; and fn reader() keeps both, lib::reader in a role position is the role and lib::reader() the fn. A path whose alias the seed does not import, or whose seed declares no such role, is left as written and refused as an undeclared role in the author’s spelling.

A role is named by a requirement: a surface row’s requires: [R, …] (rpc Orders::cancel requires: [operator];, or @rpc(requires: [R]) on the handler) or a hub binding’s requires: (spec/api.md § Surfaces and their rows, § Streams). R must be declared (surface law 4). The requirement is a property of the surface row, never of the handler, so one handler shared by two surfaces meets each surface’s; it is a boundary check, named so, and says nothing about the program’s own call paths; who holds the role is the serve site’s role source (spec/api.md § Identity sources).

@gated(role: R), which gated a subscribed handler, an expose member or a publish through the retired api binding, is refused by the parser with the replacement (requires on an rpc row, spec/api.md).

Recovery primitives (restart, restart_in_place, quarantine, reorganize, bubble, dissolve, drain) are statement-level keywords (per precedence.md); they don’t have types in the value sense. They take a locus handle or error value as argument:

restart(child);
restart(child) for 3;
quarantine(child);
bubble(err);

The compiler verifies the argument is a valid handle / error in the current scope.

F.32-2 ships a compile-time working-set estimator that projects each user-declared locus’s approximate byte cost and compares against a cache-tier budget. The estimator runs post-typecheck, pre-codegen; it doesn’t change codegen output and emits diagnostics rather than changing program behavior.

Estimator formula (per-locus, in bytes):

working_set(L) =
sizeof(L's struct) [arena + user fields with alignment padding]
+ sum(slot in L's capacity slots) cap × cell_stride
+ sum(child in L's params if locus-typed) working_set(child)

Cache-tier budgets are read from /sys/devices/system/cpu/cpu0/cache/index{0,2,3}/size on Linux at first probe (cached for the build’s lifetime); static fallbacks 32 KB / 512 KB / 8 MB apply on non-Linux or when sysfs is unavailable. See hale_types::working_set for the engine.

Per-locus annotation (F.32-2 v0.2):

@locality(L1) / @locality(L2) / @locality(L3) declare a per-locus cache-tier expectation. @locality(any) explicitly opts the locus out of any global gate. The annotation stacks with @form(...) in either order:

@form(hashmap, sync = lockfree, cap = 64)
@locality(L2)
locus Registry {
capacity { pool entries of Entry indexed_by k; }
}

The grammar surface is in grammar.ebnf § locality_annotation.

Build-flag surface (CLI, on hale build):

Flag Effect
--locality-report Emit a per-locus stderr report listing each locus’s estimated bytes, smallest-fitting tier, and a struct / capacity / children byte decomposition. Build proceeds.
--target-cache l1|l2|l3 Evaluate each locus against the named tier’s budget. Over-budget loci surface as a stderr warning by default.
--strict Convert the warning into a build error (exit 1 before codegen). Only meaningful in combination with --target-cache or a program that carries @locality(...) annotations.

Effective budget precedence (per locus):

  1. @locality(L1|L2|L3) annotation → that tier (hard contract; evaluated regardless of CLI flag).
  2. @locality(any) annotation → no budget (opts out even under --target-cache).
  3. No annotation → falls through to --target-cache global tier (or no budget when the flag isn’t set).

--strict controls warnings vs errors uniformly across both sources. The diagnostic names which source applied (per the BudgetSource::label() “@locality” / “–target-cache” attribution).

Estimator approximations (deliberately imprecise; see the working_set module doc for the full list):

  • params { } field layout uses alignment-correct accumulation (each field rounded up to its natural alignment; struct rounded up to max field alignment). Was packed-layout in v0.1; v0.2 adds the padding.
  • Arena overhead modeled as a flat 64-byte budget for synthetic headers.
  • Heap-managed primitives (String / Bytes / *View) count as 16 bytes (ptr + len); the heap buffer’s contents are not counted (lives in the locus’s arena).
  • Per-method scratch high-water mark — not modeled. The scratch arena is destroyed at method exit, so contents are transient, not resident.
  • Unbounded-cap capacity slots (no cap = N on the form) surface in WorkingSetEstimate::unbounded_slots rather than contributing zero silently.

Forward-looking / deferred items for this area now live in the decision log — see decisions.md § Deferred & future work.

Where each typing rule lives in the compiler pipeline:

  • Parse + AST construction: grammar.ebnf rules.
  • Name resolution: identifier scopes, qualified-name lookup.
  • Type inference: let-binding types, fn return types when explicit -> T omitted.
  • Type checking: assignment compatibility, function call signature, generic instantiation, projection-class constraints.
  • Locus-shape checking: contract compatibility (F.8 / F.14), k_max bounds (F.1 / runtime-checked when dynamic), lifecycle method signatures.
  • Region-lifetime checking (compile-time): no escape from shorter-lived to longer-lived scope; no sibling references.
  • Closure-cycle existence check: closure assertions reference defined values in the closure’s scope.

The Phase 1 compiler in Rust implements these checks; the Phase 6 self-hosted compiler ports them.