---
title: "Expressions and types"
description: "Operator precedence from weakest to strongest, named and positional arguments, record construction, method calls on a value, and list and option types."
modificationDate: "2026-11-30"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Expressions and types

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/reference/contract-grammar/expressions-and-types: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

```ebnf
type          = type-atom { "[" "]" } ;               (* string[] is a list of strings *)
type-atom     = "number" | "string" | "bool" | "unit" | IDENT | "action"
              | "option" "<" type ">"
              | "enum" "<" STRING { "," STRING } ">" ;
expr          = ternary ;
ternary       = binary [ "?" expr ":" expr ] ;
binary        = unary { binary-op unary } ;
unary         = ( "-" | "not" | "!" ) unary | postfix ;
postfix       = primary { "." FIELD [ "(" [ arguments ] ")" ] } ;
primary       = NUMBER | STRING | TEMPLATE | "true" | "false" | "none"
              | "some" "(" expr ")" | list | IDENT
              | IDENT "(" [ arguments ] ")"
              | "(" expr ")" | inline-match ;
list          = "[" [ expr { "," expr } [ "," ] ] "]" ;
arguments     = argument { "," argument } [ "," ] ;
argument      = expr | arrow | FIELD { "." FIELD } "=" expr ;
arrow         = ( IDENT | "(" [ IDENT { "," IDENT } ] ")" ) "=>" expr ;
inline-match  = "match" expr "{" "case" "some" "(" IDENT ")" "=>" expr
                "," "case" "none" "=>" expr [ "," ] "}" ;
```

The `binary` production is precedence-resolved, not a claim that all operators
have the same precedence. From weakest to strongest:

| Level | Operators | Associativity |
| --- | --- | --- |
| Conditional | `? :` | Nested arms parse as expressions |
| Or | `or`, `||` | Left |
| And | `and`, `&&` | Left |
| Equality | `==`, `!=` | Left |
| Comparison | `<`, `<=`, `>`, `>=` | Left |
| Additive | `+`, `-` | Left |
| Multiplicative | `*`, `/`, `%` | Left |
| Prefix | `-`, `not`, `!` | Right |
| Postfix | `.` | Left |

Parentheses override precedence. Comparisons do not create Python-style chained
comparison semantics. Logical operators short-circuit; ternary/match evaluates
only its selected arm. Conditions require booleans.

Named arguments are accepted only by the corresponding constructs: component
uses, a native module's sources and sends (including dotted names such as
`apple.desiredAccuracy=`), record construction/copy, localization (`t`), placeholders (`empty`),
canvas `surface=` bindings, `dataTransfer=DataTransfer(…)` (LLP 1094.000),
and specialized host commands such as `share`, `scrollIntoView` and the three document pickers (which take `apple.message=`). Ordinary function calls are positional. Arrow expressions are admitted
as the callbacks to `map` and `filter`, with at most item and index parameters;
they are not first-class values or event handlers.

In a GPU surface call, a complete positional or named argument may be
`color("token.name")`. The operand must be one literal string naming a
Forma colour token. This position reserves `color`. If the app also declares a
function named `color`, the surface call reports the collision. The function
can still be called elsewhere. The token constructor requires a surface argument.

An app-declared shape's call constructs a record: either all named fields, or one
positional base followed by zero or more replacements. A `list` literal is
a list of its items, left to right; their types meet as a ternary's arms do (`type-list-item` when they do
not), and a trailing comma is kept. There is no spread (`[...xs, x]` is
refused), object literal, bracket indexing, assignment
expression, `??`, `?.`, or `===`.

A call on a value, `e.f(args)`, is the roster function `f` with `e` as its first
argument, for the functions the table below writes that way: the web's string
and array methods of that name and meaning (`s.trim()`, `xs.filter(x => …)`,
`n.toFixed(2)`). `e.length` is the count of a list or text, or, when `e` is a
record whose shape declares a field named `length`, that field, as in
TypeScript; on a record without one it is refused. The free spelling (`trim(s)`,
`length(xs)`) is refused with the edit (`syntax-method-form`), and so is any
other method (`xs.reduce(…)`: `syntax-method-call`); the rest of the roster is
called as a function (`first(xs)`, `round(n)`).

A list type is `T[]`, as in TypeScript (`Item[]`, `option<number>[]`); `list<T>`
is refused with the edit (`syntax-list-type`). A `state` may declare its type
(`state picked: option<Item> = none`), which is otherwise inferred; a `derive`'s
type is its expression's and takes no annotation. `any` in an internal roster signature describes
special typing; it is not a source-language type annotation.
