---
title: "Standard functions and intrinsics"
description: "Every stdlib function with its signature, how an app's own fn of the same name shadows it, and formatting by locale."
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.

# Standard functions and intrinsics

<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/standard-functions-and-intrinsics: <what was wrong or missing>"`

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

</AgentInstructions>

The complete current `stdlib` name inventory is below. `T` and `U` express generic
relationships enforced by the type checker, not user-declarable type parameters.
Signatures are authored forms; localization's internal lowered signature differs.
An app's `fn` of one of these names shadows it in every free call (`indexOf(xs, x)`), as
a JavaScript function declared over a global does: a name the inventory gains later
never breaks an app that declared it first. A method call (`xs.indexOf(x)`, `s.length`)
is always the built-in, so a file that declares a `fn`, shape or action of that name and
also calls it as a method is refused (`syntax-method-shadowed`), since the call would
otherwise reach the app's function, which TypeScript's method never does.

`contract vocab <name>` prints one function's entry from these tables (its rows and
examples) beside the roster's signature, so what a row says here is what `vocab`
says. Every roster function has a row and an example, and each example written
`` `call` is `value` `` holds: a contract test evaluates them. A row written
`x.f(…)` is called on its first argument, as the web's method is
([expressions](https://exact.expo.dev/reference/contract-grammar/expressions-and-types.md)); the others are called as functions.

| Call | Result / restriction | Example |
| --- | --- | --- |
| `performanceNow()` | Milliseconds on the runner's clock since this launch of the app (it restarts at 0 on every launch; the driver's clock under the agent, from 0), as the web's `performance.now()`, not `Date.now()`: the date is `time.epochAtZero + performanceNow()`, with `resource time = exactTime() as shape T` declared, and that sum is what anything stored or sent takes ([timer recipe](https://exact.expo.dev/recipes/timer-that-survives-relaunch.md)). `now()` is refused (`type-now-renamed`, LLP 1109 D1) with both repairs. A read does not schedule a render, and a derive that reads it is not read again as time passes (when it is depends on the host's clock), so a value that follows the clock comes from a timer: keep the time in state that a `task … every` action writes | `performanceNow() - startedAt`, in a timer's action, is the milliseconds since `startedAt` |
| `formatShortcut(chord)` | String in the reader’s keyboard notation, empty during server rendering | `formatShortcut("Mod+Shift+O")` gives ⇧⌘O on a Mac |
| `formatTime(ms, offsetMinutes, "short" or "2-digit" or "iso")` | String; fixed offset east of UTC, in the [format locale](https://exact.expo.dev/reference/contract-grammar/standard-functions-and-intrinsics.md#formatting-by-locale) (`exactTime().utcOffset` is the zone's offset now, answered again when it changes). `"short"` is `Intl.DateTimeFormat`'s `{ timeStyle: "short" }`; `"2-digit"` is `{ hour: "2-digit", minute: "2-digit" }`, each locale's own pattern for it (`01:02 AM` in en-US, `凌晨01:02` in zh-TW); `"iso"` is locale-free 24-hour zero-padded ASCII `HH:MM:SS` (time of day only, `""` for invalid input or an offset outside ±1080 minutes) | `formatTime(1790000000000, 0, "short")` is `"2:13 PM"`; `formatTime(3720000, 0, "2-digit")` is `"01:02 AM"`; `formatTime(1790000000000, 0, "iso")` is `"14:13:20"` |
| `formatDate(msOrDayKey, offsetMinutes, "medium" or "month-year" or "month-day" or "iso")` | String; format is a literal choice, not an expression containing `or`. `"medium"` is `Intl.DateTimeFormat`'s `{ dateStyle: "medium" }`, `"month-year"` `{ month: "long", year: "numeric" }`, `"month-day"` `{ month: "short", day: "numeric" }` (`Sep 21`, `21. Sept.` in de). A number is epoch milliseconds shifted by the offset; `"iso"` is the date at that wall time, `toISOString`'s date part at a whole-minute offset (a fractional offset's sub-millisecond wall time is not clipped again) (LLP 1102 §3.4). A string must be exactly `YYYY-MM-DD` in ASCII digits and a real Gregorian date in years 0001–9999; it keeps its calendar day regardless of the offset. Every style prints `""` for invalid input, years outside 1–9999, or a non-finite offset or one outside ±1080 minutes ([dates recipe](https://exact.expo.dev/recipes/dates-and-days.md)) | `formatDate("2026-10-16", 0, "medium")` is `"Oct 16, 2026"` in en-US |
| `formatDay(then, now, offsetMinutes, "day" or "day-time" or "list" or "section")` | String; `then`'s day named from `now`'s, both at the one offset (its calendar days, so a DST change between them is not applied), in the [format locale](https://exact.expo.dev/reference/contract-grammar/standard-functions-and-intrinsics.md#formatting-by-locale) (LLP 1116.020 D8); in en-US: `"day"` is `Today`, `Yesterday`, `Tomorrow`, else `formatDate`'s `"medium"`; `"day-time"` adds ` at ` and `formatTime`'s time (`Today at 4:42 PM`, `Oct 11, 2026 at 4:42 PM`); `"list"` is Mail's and Notes' list label: the time today, `Yesterday`, the weekday two to six days back, else `10/11/26` (a later day too); `"section"` is a chat's day separator (LLP 1168.000 D5): `Today`, `Yesterday`, `Tomorrow`, the weekday two to six days either side, else `Thu, Oct 15`, with the year when it is not `now`'s (`Sun, May 4, 2025`). Pure: `now` is the app's ticked clock ([dates recipe](https://exact.expo.dev/recipes/dates-and-days.md)); `""` when either instant is outside years 1–9999 | `formatDay(1790000000000, 1790000000000 + 86400000, 0, "day")` is `"Yesterday"` |
| `formatNumber(n, "compact")` | String; admitted deterministic compact format (`1.2K`) | `formatNumber(1249, "compact")` is `"1.2K"` |
| `formatNumber(n, "decimal")`, `formatNumber(n, "decimal", digits)`, `formatNumber(n, "percent")`, `formatNumber(n, "currency", "USD")` | String; `Intl.NumberFormat`'s deterministic forms in the [format locale](https://exact.expo.dev/reference/contract-grammar/standard-functions-and-intrinsics.md#formatting-by-locale) (LLP 1116 D8), in en-US: `"decimal"` is grouped with at most three fraction digits (`1,234.567`), and with `digits`, a whole-number literal from 0 to 100, exactly that many (`minimumFractionDigits` and `maximumFractionDigits` both `digits`: `formatNumber(1, "decimal", 1)` is `1.0`, `1,0` in de), `"percent"` multiplies by 100 with none (`0.256` is `26%`), `"currency"` takes an ISO 4217 code literal and prints its symbol and fraction digits (`$1,481.47`, `-$5.00`, `¥1,235`, `CHF 5.00`; the codes are USD, EUR, GBP, JPY, CNY, INR, CAD, AUD, NZD, HKD, SGD, CHF, SEK, NOK, DKK, PLN, MXN, BRL, KRW, ZAR, TWD, ILS, PHP and VND). Each rounds the value's shortest decimal digits half away from zero, as `Intl` does (`1.005` is `$1.01`, where `toFixed` says `1.00`), and signs a negative zero (`-0`); `NaN` and the infinities print `""`. The code is written with `"currency"` only (`type-format-style`) | `formatNumber(1481.47, "currency", "USD")` is `"$1,481.47"` |
| `n.toFixed(digits)` | String; JavaScript's `Number.prototype.toFixed`: the binary value rounded (`(1.005).toFixed(2)` is `"1.00"`), a tie away from zero, `-0.001` at 2 is `"-0.00"`, `1e21` and up as `toString` prints; one declared difference: `NaN` and the infinities print `""` (LLP 1054.000.003 D7). `digits` is a whole-number literal 0–100 (LLP 1102 §3.2) | `(3.14159).toFixed(2)` is `"3.14"` |
| `formatDecimal(units, digits)` | String; an integer count of a smallest unit as a decimal, exactly: `formatDecimal(1234, 2)` is `"12.34"`, `formatDecimal(-5, 2)` is `"-0.05"`, `-0` is `"0.00"`; a count that is not an integer, or not finite, is `""`, so money is a count of cents, or `formatDecimal(round(price * 100), 2)` for a price of at most two decimals under a trillion. `digits` is a whole-number literal 0–20 (LLP 1102 §3.2) | `formatDecimal(1234, 2)` is `"12.34"` |
| `value.length` | Number; list item count or string UTF-16 code-unit count | `[4, 5, 6].length` is `3` |
| `value.isEmpty()` | Boolean; empty string or list | `"".isEmpty()` is `true` |
| `value.toString()` | String; number, boolean, or string conversion | `(42).toString()` is `"42"` |
| `floor(n)` | Number | `floor(2.7)` is `2` |
| `ceil(n)` | Number; `Math.ceil` | `ceil(2.1)` is `3` |
| `round(n)` | Number; JavaScript's `Math.round`: a half rounds up (`round(2.5)` is 3, `round(-2.5)` is -2), not away from zero. Two decimals is `round(v * 100) / 100` | `round(2.5)` is `3` |
| `parseNumber(text)` | `option<number>`; `some` for a decimal numeral in the text, trimmed as `trim` does: an optional sign, digits with an optional fraction or a fraction alone, an optional exponent (`" 12.5 "`, `"-3"`, `".5"`, `"1e3"`), the nearest double as `Number()` reads it; `none` for anything else (`""`, `"12px"`, `"0x1F"`, `"1_000"`, `"Infinity"`), past the largest finite, or a nonzero numeral that rounds to zero (LLP 1102 §3.1) | `parseNumber(" 12.5 ")` is `some(12.5)` |
| `calendarDiff(from, to, "years" or "months")` | `option<number>`; whole years or months from one `YYYY-MM-DD` date to another, counted as an age is: a period completes when `to`'s month and day reach `from`'s (months compare the day), so a Feb 29 start completes a year on Mar 1 of a common year and a Jan 31 start a month on Mar 1, as Temporal's `PlainDate.until` counts with `largestUnit` `"years"` or `"months"`. When `to` is earlier, the count back, negated; `none` when either is not a real date (LLP 1102 §3.4) | `calendarDiff("1990-05-10", "2026-05-09", "years")` is `some(35)` |
| `max(a, b)` | Number | `max(3, 7)` is `7` |
| `min(a, b)` | Number | `min(3, 7)` is `3` |
| `sin(rad)` | Number; `Math.sin`, CSS's `sin()`. The native runners' `libm` gives the same bits on every target; the web's `Math.sin` may differ in the last bits | `sin(0)` is `0` |
| `cos(rad)` | Number; `Math.cos`, CSS's `cos()`, computed as `sin` is (a point on a ring is `cx + r * cos(a)`, `cy + r * sin(a)`) | `cos(0)` is `1` |
| `sum(xs)` | Number; a list of numbers added left to right from 0, as `xs.reduce((a, x) => a + x, 0)` (`sum([])` is `0`), a list step an item; `sum(xs.map(x => …))` totals a field | `sum([1, 2, 3])` is `6` |
| `range(n)` | `number[]`; Exact's own, not the web's: the whole numbers from 0 to `n - 1` in order (`range(0)` is `[]`), a list step an item. `n` is a whole number at least 0: another literal is refused, and another computed value traps (`TypeMismatch`), refusing the commit that made it. `range(a, b)` is refused: the numbers from `a` are `range(b).slice(a)`, a window `range(n).slice(a, b)` | `range(4)` is `[0, 1, 2, 3]` |
| `text.includes(substring)` | Boolean, case-sensitive literal substring | `"grocery".includes("roc")` is `true` |
| `xs.includes(item)` | Boolean; `T` a string, number or bool, compared by SameValueZero (`NaN` is found, `-0` is `0`) | `["a", "b"].includes("b")` is `true` |
| `text.startsWith(prefix)` | Boolean, case-sensitive | `"/settings".startsWith("/")` is `true` |
| `text.endsWith(suffix)` | Boolean, case-sensitive | `"photo.png".endsWith(".png")` is `true` |
| `text.trim()` | String, JavaScript whitespace/line-terminator trimming | `"  milk ".trim()` is `"milk"` |
| `text.slice(start, end?)` | String; JavaScript's `slice` over UTF-16 code units: fractions truncate, NaN is 0, a negative index counts from the end, an omitted `end` is the end; a cut surrogate half is U+FFFD | `"Tuesday".slice(0, 3)` is `"Tue"` |
| `xs.slice(start, end?)` | `T[]`; the items, the indices clamped as text's are | `[1, 2, 3, 4].slice(1)` is `[2, 3, 4]` |
| `xs.concat(T[])` | `T[]`; both lists' items in order (`[...xs, x]` is `xs.concat([x])`) | `[1, 2].concat([3])` is `[1, 2, 3]` |
| `xs.flat()` | `T[]`; a list of lists' items in order, one level, as the web's `flat()`. It takes no depth (`flat(2)` is refused): two levels are `xs.flat().flat()`, and the web's `flatMap` is `xs.map(x => …).flat()` when the callback returns a list (`xs.map(x => …)` when it returns one value) | `[[1], [2, 3]].flat()` is `[1, 2, 3]` |
| `text.indexOf(substring)` | Number; the first match's position in UTF-16 code units, `-1` for none, `0` for `""` | `"a,b".indexOf(",")` is `1` |
| `xs.indexOf(item)` | Number; `T` a string, number or bool, compared by `===` (`NaN` is never found, `-0` is `0`); `-1` for none | `["a", "b"].indexOf("c")` is `-1` |
| `text.split(separator)` | `string[]`; the pieces between the separator's matches, left to right; `""` splits into UTF-16 code units (a cut surrogate half is U+FFFD), and `"".split("")` is `[]` | `"a,b,c".split(",")` is `["a", "b", "c"]` |
| `text.replaceAll(find, with)` | String; every match of the string `find`, left to right; `$$`, `$&`, `` $` ``, `$'` in `with` (`$1` is literal); an empty `find` inserts at every code-unit boundary; no regular expressions | `"a-b-c".replaceAll("-", " ")` is `"a b c"` |
| `text.toLowerCase()` | String; Unicode's default lowercase, final sigma kept, no locale (the web core links the case tables by use) | `"Milk".toLowerCase()` is `"milk"` |
| `text.toUpperCase()` | String; Unicode's default uppercase through the same tables, its full mappings included (`"ß"` is `"SS"`), no locale. Text on screen is uppercased by `text-transform="uppercase"`, which each platform applies as it draws; `toUpperCase` is for a string handed elsewhere: a native view's argument, `share`, a value stored or sent | `"Straße".toUpperCase()` is `"STRASSE"` |
| `first(T[])` | `option<T>` | `first([4, 5])` is `some(4)` |
| `xs.at(index)` | `option<T>`; truncates index toward zero, negative from end | `[4, 5, 6].at(-1)` is `some(6)` |
| `xs.map(callback)` | `U[]`; callback returns one value | `[1, 2].map(x => x * 10)` is `[10, 20]` |
| `xs.filter(callback)` | `T[]`; callback returns boolean | `[1, 2, 3].filter(x => x > 1)` is `[2, 3]` |
| `xs.join(separator)` | String; `xs` a list of strings, numbers or bools, each printed | `["a", "b"].join(", ")` is `"a, b"` |
| `sortBy(xs, x => key)`, `sortBy(xs, x => key, "desc")` | `T[]`; the items in a stable order of one key, a number or a string, computed once an item (the callback is `map`'s, item and index). Numbers ascend by `<` with `NaN` counted as `0` (so `NaN`, `-0` and `0` tie); strings by UTF-16 code units as `<` compares them, no locale. `"desc"` (a literal, as is `"asc"`, the default) reverses the order of the keys, not of ties: equal keys keep their input order in both directions, so a second key is an earlier sort (`sortBy(sortBy(xs, x => x.created), x => x.bpm)` is by bpm, ties oldest first). Exact's own function, not TypeScript's `toSorted`, whose comparator is refused; a locale's collation, a stored order and rows the view has not loaded are the data module's (LLP 1116.016 §5) | `sortBy([3, 1, 2], x => x)` is `[1, 2, 3]` |
| `encodeURIComponent(text)` | String | `encodeURIComponent("a b&c")` is `"a%20b%26c"` |
| `escapeHtml(text)` | String; `&`, `<`, `>`, `"` and `'` as `&amp;`, `&lt;`, `&gt;`, `&quot;` and `&#39;`, the way data enters a drag's `html=` in text and attributes | `escapeHtml("Fuji & <Rainier>")` is `"Fuji &amp; &lt;Rainier&gt;"` |
| `cssValue(text)` | String; only ASCII letters and digits, spaces, `# . , % - / ( )` and characters from U+00A0 up kept, the way data enters a `style` declaration's value in a drag's `html=` | `cssValue("red; display: none")` is `"red display none"` |
| `encodeRouteSegment(text)` | String; routing's checked segment encoding | `encodeRouteSegment("a b")` is `"a%20b"` |
| `open(router, location)` | Router | `top(open(nav, "/item/7")).name` is `"item"` |
| `push(router, location)` | Router; same top URL does not add a visit | `depth(push(nav, "/item/7"))` is `2` |
| `replace(router, location)` | Router; the top visit takes the location and keeps its id. One at another path is a new page, whose scrollers start over (at `scrollTop=`, else at their start) | `top(replace(push(nav, "/item/7"), "/item/8")).url` is `"/item/8"` |
| `back(router)` | Router | `depth(back(push(nav, "/item/7")))` is `1` |
| `select(router, tabName)` | Router | `nav = select(nav, "search")`, in an action, shows the `search` tab |
| `go(router, location)` | Router; the top, a pop to it on the selected stack, another tab whose top it is, or else a push onto the selected stack, whatever tab declares its route (into the route's declared tab: `open`) | `top(go(nav, "/item/7")).name` is `"item"` |
| `stack(router)` | `Entry[]` | `stack(push(nav, "/item/7")).length` is `2` |
| `top(router)` | `Entry` | `top(nav).name` is `"home"` |
| `depth(router)` | Number | `depth(nav)` is `1` |
| `params(router, parameterName)` | `string[]`: that parameter's non-empty values over the selected stack, bottom first, duplicates kept (one entry's own value is `entry.params.<name>`, `""` where its route does not bind it; the name must be a parameter of some route) | `params(push(nav, "/item/7"), "id")` is `["7"]` |
| `searchParam(entry, name)` | String | `searchParam(top(push(nav, "/item/7?tab=notes")), "tab")` is `"notes"` |
| `fragment(entry)` | String: what the entry's location had after `#`, fragment-encoded as the browser's `hash` is, `""` when none. It is no part of the screen: `/item/7#moves` is the visit to `/item/7`, and a `push`, `replace` or `go` that changes only the fragment changes it on that visit. Written as `path("item", id) + "#moves"`, or `href="#moves"` on a `link` to the screen shown. Once the route's content has arrived, each host scrolls to the element with that `id` in the entry's route, as a browser scrolls to a fragment (`top`, or no such element: the route's top) (LLP 1153 D5). A visit given another path with none, a page swapped in by `replace`, starts each of its scrollers over instead: at its `scrollTop=`, at the end of a list with `scroll-start="end"`, else at its start; `scroll-restoration="manual"` keeps one where it was (D5.1) | `fragment(top(push(nav, "/item/7#moves")))` is `"moves"` |
| `sharedFiles(entry, name)` | `SharedFiles`: `{files: Picked[], dropped, pending}`, the files a received share carried, by the token in the entry's `name` parameter; `pending` counts those still being copied, and a token the host did not set this launch answers no files (LLP 1133.024 D3; [`share_target`](https://exact.expo.dev/reference/developer/generate-typescript-data-source-types.md#shares-from-other-apps-share_target)) | `sharedFiles(top(nav), "files").files.length` is the count of shared files that have landed |
| `shareId(entry)` | String: the canonical lowercase UUID of the live acknowledged inbox share bound to `entry`'s `_exact_share` launch token once attachments have landed (`pending == 0`), or `""` otherwise (while copying, under `"delivered"`, on forged or restored entries, on the web, or after `acknowledgeShare(id)`) (LLP 1133.024 D3; [`share_target`](https://exact.expo.dev/reference/developer/generate-typescript-data-source-types.md#shares-from-other-apps-share_target)) | `shareId(top(nav))` passed to a save mutation so data code calls `acknowledgeShare(id)` |
| `t("key", name=value, …)` | Localized string; validates tables/placeholders | `t("greeting", name=user.name)` is the `greeting` string of the app's locale with `{name}` filled |
| `frame(id)` | `Geometry`, actions only; last layout where the viewer sees it, as `getBoundingClientRect`: in the viewport, every scroll offset and transform applied | `frame("card").height`, in an action, is the card's height as drawn |
| `scrollMetrics(id)` | `option<ScrollMetrics>`, actions only. A mounted textarea reports `scrollLeft`, `scrollTop`, `scrollWidth`, `scrollHeight`, `clientWidth` and `clientHeight` in CSS pixels. A missing or hidden field answers `none`. | In a textarea’s `resize` action, compare `scrollWidth` with `clientWidth` to detect horizontal overflow before the first scroll. |
| `rangeFrame(id, start, end)` | `Geometry`, actions only; a textarea's UTF-16 range as `Range.getBoundingClientRect()` (on a `text markup="markdown"`, the union of the atom pills the range meets, [inline atoms](https://exact.expo.dev/reference/contract-grammar/built-in-tags.md#inline-atoms-atom-atoms-atomfaces-atompress)): collapsed, the caret's rectangle; unavailable past the text, while composing, or with no host reader ([decorations](https://exact.expo.dev/reference/contract-grammar/built-in-tags.md#plain-textarea-decorations), LLP 1114.007) | `rangeFrame("composer", caret, caret)`, in an action, is where a mention popover goes |
| `measure("id")` | `Geometry`, actions only; literal id, the border box as if `height` were `auto`, other styles kept (padding, border, `min-height`, `max-height`, insets): 0 for a bare box whose children are all absolutely positioned (a navigation root); motion in flight counts at its end (a `height` transition's end value, a layout transition's laid-out box); `unavailable` before the first layout, for an id no element has, for a box with no single size (an inline run, `display: none`) and, on the web, under a `keyframes` animation of a font axis in or above it; `frame` is the laid-out box | `measure("note").height`, in an action, is the note's natural height |
| `elementFromPoint(x, y)` | `option<string>`, actions only; the `id` of the front-most of `frame`'s boxes at the viewport point, or of its nearest ancestor with one (DOM's `elementFromPoint(x, y)?.closest("[id]")?.id`): a box reaches as far as its `-exact-hit-slop`, ancestors' overflow clips apply, `pointer-events: none` and hidden boxes are passed over. The front modal's host-reported backdrop also hits where it accepts input, beneath later top-layer content | `elementFromPoint(x, y)`, in a pointer action, is `some("card-3")` over that card |
| `elementsFromPoint(x, y)` | `string[]`, actions only; own ids of every hit box, including hit ancestors, front to back; id-less boxes skipped, with `elementFromPoint`'s clips, transforms and skips. The front modal's host-reported backdrop includes its own id once where it accepts input, beneath later top-layer content | `elementsFromPoint(e.clientX, e.clientY)` sees through an Inspect overlay |
| `querySelectorAll(selector)` | `string[]`, actions only; only `[data-word~="value"]` for a declared `data-*` word; own ids of mounted, displayed, non-inert matches in tree order, excluding covered routes and unselected tabs; any other dynamic selector gives `[]` | `querySelectorAll("[data-paint~=\"accent\"]")` lists the accent nodes |

On Apple, Linux and Windows, `frame` of an inline `text` run returns the
viewport-space union of its line fragments, using the run's own font ascent
and descent and excluding collapsible spaces at a soft wrap. Preserved spaces
and tabs remain in the rectangle, including at a soft wrap. An empty run has a
zero-width rectangle at its insertion point with its font's height. Scrolling
moves this rectangle; clipping does not trim it. Linux and Windows read the acknowledged
paragraph, including multi-column placement and affine transforms; a
perspective-projected paragraph is unavailable. These readers give a cross-run
ligature's advance to its first character's run; later runs have zero-width
rectangles at its end, as in Chrome. Windows shares the Linux presenter;
runtime verification was on Linux. Android and the terminal have no inline-run
reader.

For `elementsFromPoint`, an id-less hit outside a named ancestor's own box
includes that ancestor once before lower layers. This keeps its first entry
equal to `elementFromPoint`'s nearest-id answer; LLP 1001 §1 declares the
rare difference from Chrome's raw filtered list.
An id-less hit inside that box is skipped even when it covers a named sibling.
Both point reads skip covered navigation routes, inert subtrees, and closed dialogs or popovers. Open painted top-layer content uses its presented frame and escapes clips on its authored ancestors. A macOS alert projected as an `NSAlert` sheet or an iOS UIKit confirmation has no authored hit boxes.
The front modal's host-reported backdrop names its dialog or presented route
where it accepts input, below any later popover. Its hit region is independent
of the content's clip and pointer events. Native sheet chrome outside authored
content is not part of the backdrop; neither read exposes the page or a lower modal.
For `querySelectorAll`, a closed popover or dialog is hidden by its presenter;
an open one is included when it matches. A wide split list is included only
where the host presents it (on the web); native hosts hide the unselected route.

The router functions (`open` through `shareId`) and `encodeRouteSegment`
exist only in an app with a `routes` declaration.

`<`, `<=`, `>` and `>=` take two numbers or two strings. Two strings compare as
JavaScript's do, by UTF-16 code units in order with a proper prefix first, no
locale (`"09:30" < "10:00"`, `"Z" < "a"`). `slice` and `replaceAll` work on code
units as JavaScript does and make the whole result well formed once: a lone
surrogate half is U+FFFD, since the native runners hold Unicode scalar values.
A result past the runner's string bound (64 MiB of UTF-8) traps on every
executor. `padStart` is not in Contract;
the refusals say what to write instead. Neither `indexOf` nor `split` takes
the web's second argument (a start position, a limit), and `split` takes no
regular expression.

`concat`, `split`, `sum`, `range`, `flat`, and `slice`, `includes` and `indexOf` over a list, take
list steps on the evaluation's budget as `map` and `join` do (LLP 1090): one
for each item `concat`, `slice`, `split`, `range` or `flat` makes (and `flat` one for each list it reads), taken before the list is
built, one for each item `sum` adds, and one for each item `includes` or
`indexOf` scans up to its match. A
list they build is bounded as any built value is. `sortBy` takes one step an
item, as its key is computed, and none for its comparisons: a stable merge sort
makes at most n·⌈log₂ n⌉ of them, which is the cost the budget does not count.
So 5,000 rows filtered and then sorted take 10,000 of the 65,536 steps, and
the sort of 30,000 is about 450,000 comparisons on every evaluation that reads
it, which a `derive` makes once per change of what it reads.

Compiler intrinsics and special forms additionally include:

| Form | Meaning | Example |
| --- | --- | --- |
| `pending(resourceOrMutation)` | Boolean; request is in flight | `pending(saved)` is `true` from `send saved = …` until its reply |
| `current(resource)` | Boolean; it shows an answer to its current call arguments: not its placeholder, not an answer kept from other call arguments or across idleness (`when`). A refresh of the same arguments, or a changed `with` value, leaves it true (LLP 1161.001) | `if not current(detail)` shows "loading" for a newly selected item, and not after a refresh |
| `failed(resourceOrMutation)` | Boolean; current resource request failed without an answer | `failed(weather)` is `true` once the weather request fails |
| `failure(resourceOrMutation)` | `option<Failure>`: `none` until the current request fails without an answer, then `some({ code, message, reason })` (LLP 1109 D3); `code` is the nonempty source `reason` when supplied, otherwise the infrastructure vocabulary below, the same on every host; `message` is what the agent's `state.failed` shows, and says more and differs by host; `reason` is the source error’s string `reason` (a Snapback refusal’s code such as `SLOT_FULL` or `E_RULE`), else `""`, on every host | `match failure(weather)` with `case some(f)` reads `f.code`, `"offline"` with no connection |
| `path("route", args…)` | Checked encoded route location | `path("item", "7")` is `"/item/7"` |
| `empty(field=value, …)` | Resource placeholder's zero record with overrides | `resource days = loadDays() as shape Days else empty()` shows `Days`' zero until the answer |
| `some(expr)` | Construct an option | `some(3)` is an `option<number>` holding 3 |
| `DeclaredShape(field=value, …)` | Construct a record | `Day(key="mon", ml=0)` is a `Day` |
| `DeclaredShape(base, field=value, …)` | Copy a record | `Day(d, ml=d.ml + 250)` is `d` with `ml` changed |

`failure(x).code` preserves a domain refusal code (`SLOT_FULL`, `E_RULE`, `E_OFFLINE`)
when the source throws an error carrying that string as `reason`. Otherwise it uses
one of six infrastructure words, by what reached the runner
(`runner/src/failure.rs`):

| Code | When |
| --- | --- |
| `offline` | A request the source made reached no server (no connection, DNS, TLS, a reset, the driver's `fail fetch`) and the source let the rejection through |
| `timeout` | A request's deadline (`exactTimeout`) passed, let through |
| `refused` | The host refused a request outside the app's grants or limits (admission, or a response over its size limit), let through |
| `shape` | The answer is outside the resource's declared shape |
| `storage` | A storage call failed (a coded storage refusal: `denied`, `full`, `EBUSY`, a filesystem error, storage unavailable here), let through |
| `error` | Anything else: the source's own error (a TypeScript `throw` or rejection, a Rust source's `Err`), an aborted request, a host that cannot make it, a module over its time budget |

"Let through" means the TypeScript module rethrew the `fetch` or storage
rejection or did not catch it; an error the module makes of its own is
`error`. An HTTP error status is an answer, never a failure: a module that
throws on a 500 fails with `error`. A Rust source's own error is `error` on
every host. A request the caller aborted is `error`. A response over its size
limit (`exactIndependentHttp.maxResponseBytes`, else the host's 64 MiB; a
stream's event or message over its ceiling) is `refused` on every host: the
server answered, and the host will not take more than the app said it would;
asking again gets the same answer, which `offline` would not imply. A
new code is a breaking change; branch with a default case.

`failure(x).reason` retains the domain string as well. A module turn that
fails its resource or mutation by exceeding the time budget has code `error`
and reason `overrun`. Other failures without a reason carry the empty string.
For a mutation, failure belongs to its latest send: a new send, a successful answer,
or an explicit assignment clears it. A `parallel` mutation's belongs to its latest
send to conclude: a send's failure shows unless a later send has already answered
or failed, and an earlier send's success, which does not land in the slot then,
leaves a later send's failure standing. A failed request retains its previous value,
does not retry, and does not run `then`. When a Rust mutation source returns
`BadArguments` or `Unavailable`, the sending action commits and
`failure(receipt)` reports `error` with the source's message. An unknown
source or a call that fails the declared argument checks still refuses the action.

A resource whose source answers outside its declared shape reports `shape`
and keeps the previous value or its `else` placeholder. A resource with
neither refuses the commit because it has no value to display.

Finite string parameters are written `enum<"draft", "published">`. Members must be
quoted, distinct strings, with at least one member. A literal call argument must be a
member. A dynamic argument must have a compatible declared enum type. In `==` and
`!=`, a string literal compared with an enum must be a member, in either operand
order. This includes literals inside `some(…)` and list literals when comparing
options and lists. The same rule applies to item comparisons in a list’s `includes` and
`indexOf`. A dynamic string can be compared with any enum. Shapes may use enums
too. A source answer outside the declared vocabulary fails its shape check.
Generated TypeScript uses the corresponding string literal union. An enum's placeholder
is its first member. Enums use ordinary string values at the data seam.

`Router`, `Tab`, `Entry`, and `Params` are introduced by routes. The compiler
also declares `Geometry` (geometry reads), `Failure` (`failure(x)`'s
`{ code: string, message: string, reason: string }`), `MarkdownSelection` (the `select`
payload) and `Picked` (a file input's `change` payload). None of these is
constructible. The actual sources are [`format.json`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/plan/tables/format.json),
[`runner/src/stdlib.rs`](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/runner/src/stdlib.rs), and the compiler's type/lowering
modules. A function available in JavaScript, CSS, Swift, or a data module does
not automatically become a Contract function.

## Formatting by locale

`formatTime`, `formatDate`, `formatDay` and `formatNumber` format in the locale of the
strings table the app shows (`exactTime().resolvedLocale`, so `setLocale` moves them
too), as `Intl` (ICU 78.1, CLDR 48) formats that locale (LLP 1054.000.003 D6): with a
`de` table, `26.09.2026`, `September 2026`, `13:02`, `1.234,5`, `26 %`, `1.234,50 €`,
`1,2 Mio.` and `Heute, 13:02`. An app with no tables, or with only `en` and `en-US`
tables, prints the en-US forms above. The compiler bakes each table's data into the
plan; a host carries none.

- **A table's tag chooses CLDR's locale**, the longest prefix CLDR lists (`de-AT-x`,
  then `de-AT`); a tag CLDR lists no prefix of formats as `en`. A region is a table's:
  `en-GB` prints `26 Sep 2026` and `13:02`, `de-CH` `1'234.5`. An app that wants a
  region's formats ships that region's table, which may be `{}` (it reads the base).
- **The viewer's 12- or 24-hour choice applies**: `exactTime().formatLocale`'s
  `-u-hc-h12` or `-u-hc-h23`, which Apple's hosts tell when the person set one. The
  viewer's region does not otherwise change a format.
- **Digits are the locale's own** (`ar-EG` and `fa` print their digits, `ar` Latin
  ones), as `Intl` and Apple choose them. **Dates are Gregorian** in every locale
  (`Intl`'s `-u-ca-gregory`): `th`, `fa` and `ar-SA` print Gregorian years where
  their platforms default to another calendar.
- **`formatDay`'s words** are CLDR's relative day names with a capital first letter
  (`Heute`, `Gestern`, `Morgen`), in the date's place in the medium date and short
  time (`Heute, 13:02`; en-US `Today at 1:02 PM`). A `"section"` label begins with a
  capital as a line does, the locale's first letter upper-cased (`Mercredi`,
  `Jeu. 15 oct.`, `Dim. 4 mai 2025`); its dates are CLDR's `MMMEd` and `yMMMEd`.
- **`"iso"`** is `YYYY-MM-DD` in every locale.
