Lexical structure

This document specifies the lexical layer of Hale: the set of tokens the lexer produces and feeds to the parser. The formal grammar in grammar.ebnf is…

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

This document specifies the lexical layer of Hale: the set of tokens the lexer produces and feeds to the parser. The formal grammar in grammar.ebnf is defined over these tokens.

Source encoding

Section titled “Source encoding”

Source files are UTF-8 encoded. File extension: .hl.

Outside string literals and comments, only ASCII characters are permitted. The framework’s mathematical primitives are spelled out as ASCII names; the renderer can produce Unicode for human display, but the source is ASCII-only. This commitment serves the agent-first authorship principle (no symbol-input friction) and simplifies tooling.

Whitespace

Section titled “Whitespace”

Comments

Section titled “Comments”

Doc comments

Section titled “Doc comments”

GH #1674. A doc comment is the run of lines between two tokens that each begin, after indentation, with /// (and not ////, which is an ordinary comment). Its text is those lines, each with the /// and one space after it removed, joined by a line feed, with leading and trailing blank lines dropped. Blank lines and ordinary comments may sit among the doc lines and after them; they are not part of the text.

The lexer skips a doc comment like any comment: it is never a token, so it changes nothing the grammar reads. The parser attaches it, by position, to the declaration it stands in the head of: before the declaration’s name, after the ;, ,, { or } that ends what comes before. Annotations, modifiers and keywords in that head do not separate a doc from its declaration, so a doc may stand above @rpc(requires: [clerk]) or between it and fn. The declarations a doc comment documents:

A doc comment anywhere else documents nothing: before a statement, a lifecycle hook, a block, an import, or at the end of a file. So does a /// after code on its own line, which would otherwise read as documenting the code before it. Such a comment is a warning, never an error: “this doc comment documents nothing: …” (or “this doc comment follows code on its line, …”), and the program means what it meant without it. A seed’s own files are warned about; an imported seed’s are its own check’s.

What reads the text: the documents a surface generates (spec/api.md § Documenting a surface), the editor’s hover, and hale doc (spec/testing.md), which renders a seed’s reference. The text is prose, never shape: no digest, shape hash or identity covers it.

Identifiers

Section titled “Identifiers”

There is no escaped-identifier form: a reserved word cannot be spelled as a name by quoting, prefixing or backslashing it. The only fix for a collision is a different name.

A hard keyword written where a name belongs — a params field, a local, a fn / method / parameter, a struct field, a locus or type name — is a parse error reported once, at the word, naming the word and the declaration it was written in:

work.hl:8:9: parse error: `while` is a reserved word and cannot name
a params field; rename it (Hale has no escaped-identifier form —
spec/tokens.md lists every reserved word)

The parser then resumes as if the declaration had been named, so the rest of the file still parses and the one error is not followed by the consequences of the abandoned declaration (a later } reported as a stray token, a literal of the type reported as a block, the same word reported again at every use site). Every use of the SAME word as a name after the first is part of that one mistake and is not reported again. This section is the canonical list the diagnostic points at.

Reserved words (keywords)

Section titled “Reserved words (keywords)”

Hale has two kinds of keyword (decision F.43):

The list is pinned: keywords.txt holds every hard and contextual keyword, a test holds it equal to the compiler’s, and a change to it is a decision entry in decisions.md and a CHANGELOG fragment (STABILITY.md § Keywords).

Two declarations of a contextual word stay refused, because the name would collide with the syntax the word introduces at the use site:

Declaration keywords (hard)

Section titled “Declaration keywords (hard)”
locus type const fn
import interface

export is no keyword (F.47): @export is an annotation, read as the identifier export after @ like every other annotation name (§ Annotation inventory), and export is free as a name elsewhere.

module is not a keyword (F.57): the module NAME { … } declaration was removed, and module lexes as an ordinary identifier, so a local, a field, a parameter or a fn may be named module. A program that still writes module NAME { at top-level declaration position is refused there with one located error (a module is a directory, reached by import).

interface (F.20) declares a structural interface — a named set of method signatures. Any locus whose method set is a superset structurally satisfies the interface (no impl I for L declaration). Phase A (typecheck) and Phase B (codegen vtable dispatch) both shipped 2026-05-11; interface values are usable as fn params, fn returns, locus param/field values, and @form(vec) cell elements. Interface elements in tuples / fixed arrays remain gated on the broader composite-construction coercion design (same gap as tuple-of-LocusRef escape).

perspective is no keyword, and neither are reperspective, serves, serialize_as and stable_when: perspectives were removed (F.55), and each is an ordinary identifier. A program that still writes one of the removed forms — perspective P { … }, a : serves P clause, a perspective(P) type or reperspective self.<field> as <Impl>; — gets a located parse error naming the replacement: declare an interface and take it as a param, generic where the implementation’s type matters.

Locus member keywords (contextual)

Section titled “Locus member keywords (contextual)”
params contract bus capacity
as_parent_for indexed_by

params, contract, bus and capacity are keywords at locus-member position, where each introduces its block. capacity introduces an F.22 capacity { ... } block carrying zero or more pool X of T; / heap Y of T; slot declarations. as_parent_for and indexed_by are keywords only in slot-clause position inside a capacity block: pool P of T as_parent_for ChildL; (v1.x-4 — share the slot’s allocator with a child locus’s same-named slot at accept time) and pool P of T indexed_by field; (v1.x-FORM-4 — names the hashmap key field on a @form(hashmap) cell type), and after a struct field’s type, checks: bounded[Check; 16] indexed_by name; (a wire map, spec/api.md § Codecs), there followed by -> <field> for a map of values (indexed_by name -> status). The slot-kind words pool and heap are contextual idents — they lex as ordinary Idents and the parser recognizes them only in slot-decl head position inside a capacity block. So fn pool_alloc(...), let heap = ..., and type Heap { ... } all stay admissible outside capacity blocks. Same F.10-style narrowing the closure-keyword family uses for approx / within.

Lifecycle keywords (contextual)

Section titled “Lifecycle keywords (contextual)”
birth accept release run
drain dissolve on_failure

Keywords at locus-member position, where each introduces its hook (run() { … }, accept(c: Child) { … }, on_failure(c: Child) { … }); birth and dissolve also name an epoch spec inside a closure body, and a @phase_effects( … ) key or a claim’s during phase names any of them. A field, parameter, local or free fn may be named run; a locus METHOD may not (above).

mode (not a keyword)

Section titled “mode (not a keyword)”

mode is not a keyword (F.61): it lexes and parses as an ordinary identifier in every position, a locus method’s name included. At locus-member position, mode NAME followed by (, -> or { is refused there with one located error naming the fn to write:

work.hl:4:5: parse error: locus modes were removed in 0.38: write `fn rebalance(...)` (a mode compiled as an ordinary method; spec/decisions.md F.61)

Projection-class keywords (contextual)

Section titled “Projection-class keywords (contextual)”
projection rich chunked recognition
tier

Keywords in a locus header’s post-: list (locus Cache : tier 1, projection rich); rich, chunked and recognition also in type position when a < follows (rich<Sample>).

Placement keywords (F.31)

Section titled “Placement keywords (F.31)”
placement cooperative pinned pool core cores
topology node l3 reserve replicas

placement introduces the placement { } block on main locus (F.31); topology introduces the topology { } block (topology Phase 1b). cooperative / pinned are placement-spec keywords inside placement { }. pool, core, and cores are contextual idents — recognized only as kwarg names inside cooperative(pool = X) / pinned(core = N) / pinned(cores = A..B | A..=B | {a, b, c}) placement specs (topology Phase 1a). Phase 1b adds pinned(node = N) / pinned(l3 = name), plus the topology, node, l3, and reserve block keywords. Phase 1c adds replicas (a second pinned(...) kwarg, e.g. pinned(cores = A..B, replicas = K)). All are contextual idents — outside their positions they lex as ordinary Idents and can name fns / vars / fields (same F.10-style narrowing the closure keyword family uses). Note L3-domain names go through the identifier rule, so a hard keyword (e.g. match) can’t name a domain — use a plain identifier. cores range bounds and set elements are integer literals; the range reuses the expression tokens .. (exclusive) / ..= (inclusive).

schedule is no keyword (F.56): the pre-F.31 : schedule cooperative | pinned per-locus annotation no longer exists. Placement is a main-only deployment seam (bindings’s sibling), not a per-locus annotation.

Closure keywords (contextual)

Section titled “Closure keywords (contextual)”
closure epoch persists_through resets_on
resets_per_epoch

closure is a keyword at locus-member position (closure NAME { … }); the other four lead a clause inside a closure body — epoch when an epoch spec follows it, the three lists when their ( does.

approx and within are contextual keywords, recognized only inside a closure { ... } block body (and only in the specific positions the closure-assertion grammar admits them). They lex as ordinary Idents elsewhere, so fn approx(...) and let within = ... are admissible outside closure bodies. Same F.10-style narrowing the framework vocabulary uses post-dot. Shipped 2026-05-11; resolves notes/hale-friction.md 2026-05-10 closure-keyword-shadows-helper-ident.

captures and inline (v1.x-VIOLATE, F.27) are contextual keywords. captures is recognized only as a clause keyword inside closure { ... } body, in the captures: f1, f2 ... ; production. inline is recognized only as an epoch_spec variant (immediately after epoch in a closure clause). Both lex as ordinary Idents elsewhere — so let captures = ... and fn inline(...) stay admissible outside closure bodies. Same F.10-style narrowing.

Recovery primitives (contextual)

Section titled “Recovery primitives (contextual)”
restart restart_in_place quarantine reorganize
bubble

Keywords at statement head when a ( follows (restart(c) for 3;, bubble(err);), and as event names in persists_through( … ) / resets_on( … ). Elsewhere they are names (self.restart, let restart = …, fn restart() in a locus); a free fn may not take one (above).

violate (v1.x-VIOLATE, F.27) is a contextual keyword: recognized only as the leading token of a statement inside a locus method body (the violate_stmt production in grammar.ebnf § 13). Outside that position it lexes as an ordinary Ident, so let violate = ... and fn violate(...) stay admissible. The optional trailing with in violate NAME with EXPR; is the previously-reserved keyword with (no longer reserved-for-future-use); recognized only as the separator before the payload expression in this production.

Contract keywords (contextual)

Section titled “Contract keywords (contextual)”
expose consume inferred

Keywords inside a contract { } block (expose / consume at a member’s head) and after a params / contract head’s : (inferred).

Bus keywords (contextual)

Section titled “Bus keywords (contextual)”
subscribe publish on of
where

Keywords inside a bus { } block (subscribe / publish at a member’s head, of type T after the subject, where key == … on a keyed subscription), in a capacity slot (heap items of T), in a claim (publish T; / subscribe T; grants, bound C <= N on paths from G) and after a binding entry (where same_process). publish is also an effect-class name and an @effects(publish: { … }) key.

Statement / expression keywords (hard)

Section titled “Statement / expression keywords (hard)”
let mut if else
match for in while
return break continue true
false nil self

These are hard keywords. tier moved to the projection-class words (contextual); in after . is a member name (d.in(s)), and locus and type are member names after . too (err.locus).

Bindings are immutable by default. let mut x = ... declares a mutable binding; reassignment via x = ... is permitted. Without mut, reassignment is a compile-time error.

self is meaningful only inside a lifecycle block, a locus fn, or a closure block. It refers to the enclosing locus’s own params and contract-exposed state. Outside such a block, self is a parse error.

Predefined type names (NOT keywords)

Section titled “Predefined type names (NOT keywords)”
Int U64 I32 U32
I16 U16 I8 U8
Float Decimal U256 I256
String Bool Time Duration
Bytes BytesView StringView BytesMut

U256 / I256 (GH #1934) are the 256-bit integers; in expression position U256::f and I256::f name the functions of std::u256 and std::i256 (U256::from_int(5), U256::parse(s) or ...), and they have no literal of their own (spec/types.md § U256 and I256). U64 (GH #2121) is the 64-bit unsigned integer: U64::f names the functions of std::u64, an integer literal whose place is a U64 is one, and a decimal integer literal past Int’s max (2^63 through 2^64 - 1) is one by itself; past 2^64 - 1 it is a lex error (spec/types.md § U64). I32, U32, I16, U16, I8 and U8 (GH #2132) are the fixed-width integers: U8::f names the functions of std::u8 (and so on), and an integer literal whose place is one is one, held to its range where it is written (spec/types.md § Fixed-width integers).

BytesView / StringView (F.30) are non-owning views over a BytesBuilder’s buffer; BytesMut (#3) is a raw {ptr, len} writable/readable window (a Topic.write ring slot or a MirrorRing window). See spec/types.md. Time and Duration are declared by the stdlib’s seed (type Duration = quantity Int in ns;, type Time = point Duration;, spec/units.md § The stdlib’s time catalogue); a type position reads either name as that declaration, whose values keep the primitive’s representation.

PascalCase per the type-name convention. The lexer emits these as Ident tokens; the parser recognizes them by name in type position only. In expression / namespace position, these names are unreserved — time::sleep is a regular path because time (lowercase) is an ordinary identifier. This eliminates the lexical collision between primitive type names and stdlib namespace names that would otherwise occur.

Shadowing a predefined type name with a user-defined type (type Int = ...) is permitted by the grammar but produces a compiler warning. A scalar declaration (a quantity, a point, an identity, a range) or a unit of such a name is an error (spec/units.md § The laws, law 12).

Reserved for future use

Section titled “Reserved for future use”

None. trait, impl, async, await and macro were reserved here with no grammar; F.47 unreserved all five, and each is an ordinary identifier, free as a field, parameter, local, type or fn name. A feature that ever takes one of them takes it as a contextual keyword (F.43).

(with and where left this list earlier: v1.x-VIOLATE recognizes with as a contextual keyword inside the violate_stmt production, and Form K recognizes where as the suffix keyword on binding_entry carrying operational constraints.)

yield is a statement keyword (m26b) — explicit cooperative yield point; lowers to a bus-queue drain in codegen. Listed under cooperative-scheduler keywords.

terminate is a statement keyword — ends the current locus’s lifecycle from inside one of its own methods (the locus analogue of return). Only valid inside a locus method body. See spec/semantics.md § “terminate”.

Cooperative-scheduler keywords (contextual)

Section titled “Cooperative-scheduler keywords (contextual)”
yield
terminate

Keywords at statement head when ; follows (yield;, terminate;); names everywhere else (fn yield_now(), let terminate = …, self.terminate).

Fallible / error-addressing keywords (v1.x-FORM-1)

Section titled “Fallible / error-addressing keywords (v1.x-FORM-1)”
fallible fail or raise

All four are contextual keywords, recognized only in the positions described below. Outside those positions they lex as ordinary Ident tokens, so existing code that uses let fail = ..., fn or_else(...), or let raise = ... stays admissible.

The implicit binding err is in scope on the RHS of an or clause and resolves to the fallible call’s payload value (typed as the fn’s fallible(T) marker). This is a typecheck rule, not a lexer rule — err lexes as an ordinary identifier everywhere; the typechecker just introduces it as a binding in the or RHS scope.

Rule of thumb for use:

Unit dialect words (GH #1076)

Section titled “Unit dialect words (GH #1076)”
unit quantity point distinct

All four are contextual keywords (spec/units.md § Declarations), each recognized in one position and an ordinary Ident everywhere else, so a local, field, parameter, fn or method may still be named by any of them:

range, round and origin name the clauses of a scalar type’s { } block (type Byte = Int { range: 0..256; }) and are not words anywhere else. in stays a hard keyword; after . it is a member name, so d.in(s) is an ordinary method call.

Surface words (GH #1417)

Section titled “Surface words (GH #1417)”
api rpc requires

All three are contextual keywords (spec/api.md § Surfaces and their rows), each recognized in its positions and an ordinary Ident everywhere else:

api::serve( … ) is a call whose arguments after the surface and the transport are named (as:, receivers:, bound:, on_full:); no other call takes named arguments (spec/api.md § Serving). serve itself is no keyword: the call is recognized by its path, and serve is a name everywhere. Nor are http, principals and roles (F.56): http is the stdlib module of the http::Rpc transport, and principals: and roles: are ordinary params of the transports and hubs.

Fleet words (phase 4)

Section titled “Fleet words (phase 4)”
fleet host

Both are contextual keywords (spec/verification.md § Fleet composition), ordinary names everywhere else:

Operators

Section titled “Operators”

Arithmetic

Section titled “Arithmetic”
+ - * / %

Comparison

Section titled “Comparison”
== != < > <= >=

Logical

Section titled “Logical”
&& || !

Bitwise

Section titled “Bitwise”
& | ^ << >> ~

Assignment

Section titled “Assignment”
= += -= *= /= %= &= |= ^=

Closure / approximation

Section titled “Closure / approximation”
~~ equivalent to `approx`; tests value approximate-equal
within a stated tolerance band. Used in closure tests.

Bus send

Section titled “Bus send”
<- Send a typed message on a declared bus subject:
`"subject" <- value;`. The left side names a subject
declared in the locus's `bus { publish ... }`; the
right side is the typed payload. Same Erlang-shape
as `Pid ! Msg`; one-direction (subscribe is
declarative, not an operator).

Member access / call / index

Section titled “Member access / call / index”
. :: ( ) [ ]

Type / generic

Section titled “Type / generic”
< > -> => : ::

(Note: < and > are overloaded between comparison and generic arguments. The parser disambiguates contextually.)

Punctuation

Section titled “Punctuation”
; , { }

Annotation prefix (v1.x-FORM-1)

Section titled “Annotation prefix (v1.x-FORM-1)”
@

@ introduces a decorator-shaped annotation that decorates the declaration immediately following it. v1 recognizes one such annotation: @form(<name>, <args>...), which sits above a locus declaration and picks an efficient lowering (see spec/forms.md).

Lexically, @ is a single-character punctuation token. The parser routes the following form ident as a contextual keyword in this position only.

Reserved for future annotation surfaces; user-defined annotations are not in v1.

Reserved (no v0 meaning)

Section titled “Reserved (no v0 meaning)”
# $ ? ?? ?:

One position gives ? a meaning: after a record field’s name, x?: T declares an optional field (spec/types.md § Optional fields, F.52). Anywhere else, after a type (T?) included, it is a parse error.

Literals

Section titled “Literals”

Integer literals

Section titled “Integer literals”

Float literals

Section titled “Float literals”

Quantity literals (GH #1076)

Section titled “Quantity literals (GH #1076)”

Decimal literals

Section titled “Decimal literals”

Time / duration literals

Section titled “Time / duration literals”

String literals

Section titled “String literals”

Raw strings

Section titled “Raw strings”

A raw string (GH #1948, 2026-11-15) is r before the opening quote: r"C:\temp\new", r"^\d+\.\d+$". Nothing in it is an escape — a \ is a backslash — and { is text, so it reads exactly as written. It ends at the first ". A text that holds a " puts one or more # between the r and the quote and closes with a " followed by as many: r#"say "hi""#, and r##"a "# inside"## for a body holding "#. This is Rust’s spelling, also Python’s r"…" for the no-# form.

hale fmt keeps it as written, like every other token.

Block strings

Section titled “Block strings”

A block string is a raw, multi-line string literal. It is for text that has its own syntax — Hale source written into a test fixture, a SQL query, a JSON document — which an escaped one-line string turns into \" and \n soup:

const PROGRAM: String = """
fn main() {
println("a\n{b}");
}
""";

Its value is the program exactly as it reads, ending in one line break (the blank line before the closing fence): the escaped string "fn main() {\n println(\"a\\n{b}\");\n}\n". The rules:

hale fmt moves a block string with the code around it: the closing fence stands one level deeper than the line the literal opens on, and every line of the text keeps its distance from the fence, which is what keeps the value. The formatter’s re-lex gate holds a block string to its value rather than its raw text.

Why this spelling. The lexer had two string bodies, the escaped "..." (with f" and b" prefixes) and the backtick span of time literals and field tags; it had no raw form, and earlier drafts of this section listed r"..." and """...""" aspirationally. A raw block answers the text it exists for: embedded Hale, SQL and JSON carry escapes of their own (\n inside a Hale string, \" inside JSON), so a block that processed escapes would double every backslash in them, and a raw r"..." on one line would still be one line (it was added later, GH #1948, for the one-line case: a regex or a path). The fence is the string’s own quote, so the literal reads as a string; its length grows instead of a # count (Rust’s r#"), so a body holding the form itself needs no other punctuation; and the indentation is the closing fence’s, so the text indents with the code that holds it. The fence-length and closing-indent rules are C# 11’s raw string literals; the closing-indent rule is also Swift’s and Java’s text blocks’.

Boolean literals

Section titled “Boolean literals”

Nil literal

Section titled “Nil literal”

Bytes literals

Section titled “Bytes literals”

Built-in identifiers (not keywords)

Section titled “Built-in identifiers (not keywords)”

These identifiers have semantic meaning in the standard library and are conventionally reserved, but are not parser-reserved keywords:

B c sigma phi
k_max span_max
sum prod min max
length empty
print println eprint eprintln
to_string len abs
starts_with contains ends_with
check_closures Int Float

Int(x) (v1.x-11) is a built-in cast — explicit Float → Int narrowing via fptosi (truncate toward zero). Int arg is the identity; other types reject. There is no implicit Float → Int conversion; the user must commit via this constructor-shaped call. Float(x) is its widening twin — Int → Float via sitofp, Float arg the identity, other types reject. These two are the only casts; the remaining primitive-type names are types and nothing else. to_string(x), len(x), abs(x), min(a, b), max(a, b), starts_with(s, p), contains(s, p) and ends_with(s, p) are similarly bare-name builtins, as is check_closures() at statement position. ends_with (GH #1995) answers only where the program declares no fn of that name: the name was free before it was a builtin, so a program’s own fn ends_with keeps it, and it is not among the claimed names below.

A bare builtin call is the same call in either position. In statement position the expression is evaluated and its value discarded, so len(s);, Int(3); and min(1, 2); are legal (if pointless) statements rather than a narrower vocabulary: a name the compiler answers in expression position it answers here too. The four printers and check_closures() return no value and so are statement-position-only; the bounded[T; N] intrinsics keep their own statement spellings, with push / at / set carrying an or disposition because they are fallible.

Names a free fn may not take (GH #863, GH #880)

Section titled “Names a free fn may not take (GH #863, GH #880)”

These names are claimed at the call site, ahead of any user declaration:

sum prod min max
abs to_string Int Float
len starts_with contains
print println eprint eprintln
check_closures __fmt

sum( and prod( have their own production at expression head (the closure-assertion accumulators — see semantics.md § Closure-test evaluation). min, max, abs, to_string, Int, Float, len, starts_with and contains are answered by a call-expression arm that matches the callee name before it consults the program’s free fns. check_closures is answered the same way at statement position. __fmt is what an f-string interpolation desugars into.

A declaration of one of those names could therefore never be reached, so a free fn may not take it — the parser refuses the declaration, at the name:

`abs` is a built-in call form and cannot name a fn; rename it
(every `abs(...)` call site lowers to the builtin, so the
declaration could never be reached …)

The four printers are claimed for the opposite reason, and it is the stronger one: they resolve through the program’s fns first, and the Hale-source standard library is merged into the same global fn namespace. A fn print(a: Int) therefore captures the library’s own print("…") calls, and a program that never mentions print again fails to build with fn `print` arg 0 type mismatch: expected Int, got String. Whether a given printer is reachable that way is an accident of what the library happens to call today, so all four are claimed.

The rule is on the declaration, not the name. A locus method and an interface method may both still be called sum, len or contains — they are reached through a receiver (self.sum(), b.len()), which no builtin claims, and the standard library’s own mirror_ring.hl and bytes_builder.hl declare fn len().

Everything else in this section’s table stays available to a free fn. B, c, sigma, phi, k_max, span_max, length and empty are conventionally reserved but no call site dispatches on them. The bounded[T; N] intrinsics (count, clear, truncate, push, at, set) and the accumulator vocabulary (count, mean) are recognized only when the argument IS a bounded receiver, or inside a closure assertion. The rest of the element-chain vocabulary (map, filter, into, any, all, first, find, each, take, skip, enumerate, sort_into, reverse_into, group_count_into — semantics.md § Element chains) is recognized only after a ..

A declaration shadows a bounded intrinsic (GH #892)

Section titled “A declaration shadows a bounded intrinsic (GH #892)”

The six bounded[T; N] intrinsics dispatch on the type of their first argument, so where a program declares one of those names the two readings can be told apart — and the program’s own declaration wins:

A free fn whose first parameter is a bounded[T; N] answers every call of that name whose first argument is a receiver of that same bounded[T; N], at any arity the declaration accepts. The intrinsic answers every other call.

type Window { id: String; samples: bounded[Int; 8]; }
fn count(xs: bounded[Int; 8]) -> Int { return 8801; }
fn main() {
let mut w = Window { id: "w1" };
push(w.samples, 1) or raise;
println(count(w.samples)); // 8801 — the declaration
}

The rule is held by the typechecker and by codegen alike, so hale check and hale build resolve such a call to the same fn. It is a shadow, not a refusal: no declaration is rejected, and a program that declares none of the names is unaffected.

Element type and capacity are part of the match, and that is load-bearing rather than fussy. The Hale-source standard library is merged into the same global fn namespace and calls these intrinsics on buffers of its own, so a shadow keyed on the name alone would retarget the library’s calls at the user’s declaration — the capture that makes the four printers claimed names. A declaration over some other bounded is simply not the receiver’s, and the intrinsic answers.

Method position is untouched: f.get(i) and the element-chain terminals (f.filter(…).count()) are reached through a receiver, which no free fn claims.

Until GH #863 / GH #880 the declaration was accepted and the divergence appeared later, in one of two shapes. hale check passed and hale build refused the program with an unlocated unsupported in codegen v0 (len, starts_with, contains, print, eprintln, check_closures, __fmt); or the program BUILT and silently ran the builtin instead of the body — a wrong answer with no diagnostic anywhere (abs, to_string, Int, Float, and a two-arg min / max).

print and println are built-in functions, always in scope without an import. They write to stdout. print does not emit a trailing newline; println does. They accept any number of arguments of any displayable type and concatenate.

publish is a built-in function in scope inside any locus that declares matching bus { publish SUBJECT of type T; }. The compiler verifies the subject and type at each call site. Out of scope in loci with no publish declaration.

The framework names (B, c, σ, φ) use ASCII spellings in source: B, c, sigma, phi. The framework’s k_max is k_max or its named alias span_max.

Tokenization rules

Section titled “Tokenization rules”

Reserved character classes

Section titled “Reserved character classes”

The following characters are not part of any token in v0 and are lexer errors if encountered outside a string or comment:

` (outside time literal) \ (vertical bar mid-token, not || or |=)
' (outside a byte literal)

(Backticks are reserved for time literals only; bare backslash outside a string literal is illegal.)

Annotation inventory

Section titled “Annotation inventory”

Annotations are @-prefixed contextual idents (never reserved words), so a program may still use these names as identifiers. They attach to the declaration that follows.

annotation attaches to meaning
@ffi("c") free fn external C-ABI binding
@export fn / locus WASM module export; persistent singleton
@form(kind) locus storage form (vec / hashmap / set / ring_buffer / lru_cache / heap)
@locality(tier) locus placement locality tier
@bounded locus opt into the memory-bound proof
@unbounded fn acknowledge intentional unbounded allocation
@hot fn certify a hot path (promotes advisories to errors)
@vectorize / @vectorize(min_width: N) fn every innermost loop must be vectorized on the build’s target, at least N lanes wide when given (spec/semantics.md § Vectorized loops)
@budget(alloc_per_call = N, stack_bytes = N, block_points = N, publish = N, fanout = N) fn quantitative budgets, comma-separated
@effects(none: {…}) fn forbid effect classes, checked transitively
@phase_effects(phase: {…}, …) locus per-lifecycle-phase effect contract
@effects(causes: {…}) fn effect classes this fn may cause via bus edges
@supervised locus every locus in the subtree has a failure policy
@sealed locus this locus’s params are readable only from inside it
@repo(T) locus the locus is where T’s state lives; held to the method set and the state classes (spec/api.md § Repositories)
@idempotent / @not_idempotent fn a @repo method’s marker: repeating the write is, or is not, safe
@raise free fn the conversion an or raise applies from the fn’s one parameter’s type to its result’s; implies @effects(none: {syscall, publish, spawn, block}) (spec/semantics.md § or disposition)
@secret fn param lint: flags a value reaching a publish or log/file sink in the same body
@effects(publish: {…}) fn the allowed publish set
@effects(depends: {…}) locus complete set of subjects that may transitively reach any handler
@effects(is: {…}) fn classify this fn as a source of the named effect classes
@effects(only: {…}) fn CLOSED contract — the inferred set must be a subset of these
@no_syscall @no_block @no_ffi @no_publish @no_spawn @no_recursion @deterministic fn sugar for the @effects(none: …) forms
@no_panic fn no reachable trap (disposition coverage — a different analysis)
@rpc / @rpc(requires: [ROLE, …]) locus fn a row of the seed’s default surface (spec/api.md)

The fn CONTRACT annotations — @unbounded, @hot, @budget(...), @vectorize and the effect assertions — stack on one fn in any order; @ffi and @export say what a declaration IS and take the slot alone. A stack that contradicts itself (the same annotation twice, or @unbounded with a contract that forbids allocation) is a check-time error at the annotation. See spec/verification.md § Decorator stacks.

effect NAME = { A, B }; optionally DEFINES a class as the union of others. A composed class owns no bit of its own, so forbidding it forbids every member, and a fn reaching a member carries it. Members may be built-ins or other declared classes; a definition cycle is rejected.

The built-in classes are syscall, block, time, entropy, env, ffi, publish, spawn, recursion, alloc, secret_use (GH #436 — a privileged operation over confined secret material, carried by std::secret’s methods), and stdio (a write to standard output or standard error; a sub-class of syscall, carried with it by println, print, eprintln, eprint and every stdlib leaf writing fd 1 or 2). Every built-in name is reserved: effect secret_use; — or effect syscall; — is an error, because the built-in wins at every use site and the declaration would be a silent no-op.

effect NAME; is a top-level declaration, not an annotation: it introduces a user effect class that is: / none: / causes: then name like a built-in. effect is a contextual keyword — recognized only at the start of a top-level item followed by an identifier and ;, so an existing effect binding is unaffected. Declared classes are single-seed (see spec/verification.md).

Effect annotations stack with each other and with @hot / @budget(...); see spec/verification.md for what each class means and where its truth comes from.

group NAME = { … } [may_be_empty]; is a top-level declaration of claim vocabulary, domain NAME = { … }; declares a closed index domain for effect families (effect knowledge(wing);), and claims { … } is a main-locus member holding named bundle-level claims (GH #382). The claim verbs are forbid reaches (with via / during / avoiding modifiers), only edges (grant enumeration), bound (path budgets over user classes, plus the built-in secret_use — the one counted built-in with no @budget spelling), require subscribes|publishes (existence), require sealed(all G) and require attributed(all C) (GH #436 — universals over the closed world rather than over a path), cover, and count. All introducers — group, claims, domain, forbid, reaches, via, may_be_empty, edges, bound, require, sealed, attributed, all, cover, count, during, avoiding, seed — are contextual keywords, recognized in their positions only, so existing identifiers with those names are unaffected. @budget(<user class> = N) bounds calls to declared carriers of the class. See spec/verification.md § Claims and spec/grammar.ebnf.