This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index at /llms.txt, or add .md to any page's URL.
Contract has closed types: number, string, bool, declared records, option<T>, and T[]. Component interfaces can also use the bare type action. There is no authored any, nullable field shorthand, or arbitrary JavaScript object. The compiler infers states and derives, and a state may declare its type (state picked: option<Item> = none); fields, component props, injections, and function signatures declare theirs. A list type is written as in TypeScript: string[], Item[], option<number>[].
contract
shape Fields
title: string
pinned: bool
component Editor
state fields = Fields(title="Untitled", pinned=false)
action rename(value: string)
fields = Fields(fields, title=value)
action pin
fields = Fields(fields, pinned=not fields.pinned)
view
column gap=8
input value=fields.title input=rename testId="title"
button press=pin testId="pin"
text (fields.pinned ? "Unpin" : "Pin")
Fields(title=…, pinned=…) constructs a record and must supply every field exactly once. Fields(fields, title=value) copies the base and replaces named fields. It does not mutate the base. Fields are read with fields.title. Only app-declared shapes can be constructed this way; compiler-owned shapes such as Router and Geometry come from their designated operations.
Records, lists, and options are values; equality is structural. Shape definitions must be finite and nonrecursive. Required record fields are never defaulted by record construction. A resource's placeholder is a separate concept.
An option<T> is either none or some(value). Unwrap it explicitly:
text
derive selected = first(items)
derive caption = match selected {
case some(item) => item.title,
case none => "Choose an item"
}
The some branch's binding exists only in that branch. Both arms are required. A state initialized to none needs enough information elsewhere, usually an action's assignment of some(...), to infer the element type, or a declared type (state picked: option<Item> = none). Actions, derives and the view all see that type. Similarly, [] needs an inferable list element type. A list literal such as [1, 2] holds its items, which share one type; a list the screen keeps for the session (a selection, open ids) is built in Contract, and a list the app keeps across launches comes from the data module.
Is this helpful
Last updated November 30, 2026
Exact Docs