Gui

:= []

The whole application-facing platform under one import. Build a tree with the element constructors and their property records, adjust an element with the modifiers on Elem, and answer events with the constructors on Action: Action.none(), Action.update, Action.delegate, or Action.task.

Files

:= []

Dir

:= []

Operations requiring read authority for a particular directory.

Read

:= DirRead

An opaque, typed handle granting read access to one directory. It can be retained in application state and cannot be constructed by applications.

list! : Read => Try(List(Entry), FileErr)

List direct children without following symbolic links. Results are bounded by the host's entry and metadata limits.

open_dir! : Read, Str => Try(Read, FileErr)

Acquire one direct ordinary child directory as a new read handle. name must be a single ordinary entry name; traversal and links are rejected.

read! : Read, Str => Try(List(U8), FileErr)

Read one direct ordinary child file without following symbolic links. Reads are bounded by the host and return ResourceLimit when the file is too large for one in-memory value.

sha256! : Read, Str => Try(Str, FileErr)

The SHA-256 digest of one direct ordinary child file, as 64 lowercase hexadecimal digits. The host streams the file without following links, so no byte of it becomes an application value; a file over the host's hash bound answers ResourceLimit.

watch! : Read => Try(Watch, FileErr)

Watch this directory's direct children: a child created, removed, renamed, or written is reported by name in a Changed wait. The watch is derived from this grant, and nothing beneath a child directory is reported.

resource : Read -> DirRead

The shared representation behind this handle. It is the seam the platform's own modules use to hand a directory to the host, as Sqlite and Audio do. The representation is itself opaque, so it grants nothing an application can act on.

ReadWrite

:= DirReadWrite

An opaque, typed handle granting read and write access to one directory. Only the host's private application-data directory is reached this way.

read_utf8! : ReadWrite, Str => Try(ReadUtf8, FileErr)

Read one bounded UTF-8 direct child.

File

:= []

Operations requiring read authority for one particular file.

Read

:= FileRead

An opaque, typed handle granting read access to exactly one file. It names no directory, so it reveals no sibling, and it can be retained in application state but not constructed by applications.

read! : Read => Try(List(U8), FileErr)

Read the whole file. Reads are bounded by the host and return ResourceLimit when the file is too large for one in-memory value.

sha256! : Read => Try(Str, FileErr)

The SHA-256 digest of the file, as 64 lowercase hexadecimal digits, streamed by the host under the same bound as a directory's sha256!.

resource : Read -> FileRead

The shared representation behind this handle, for the platform's own modules, as Sqlite uses it. It grants nothing an application can act on.

from_resource : FileRead -> Read

Wrap the shared representation, for the platform's own modules that hand a file to an application, as a drop target does. An application cannot produce the representation, so this grants nothing.

pick_directory! : Access => Try(Choice(Selection), FileErr)

Acquire the read-only project grant provisioned by the host. This function does not display trusted UI; interactive hosts must source the grant from trusted selection. Without a provisioned grant it returns AccessDenied.

pick_file! : Access, List(FileType) => Try(Choice(FileSelection), FileErr)

Acquire a read-only grant for one file the person chooses, offering only types. An empty list offers every file. Without trusted selection or a provisioned file it returns AccessDenied.

recent! : Access => List(Recent)

The application's recent files and folders, most recent first, each checked against what is at its place now.

reopen_file! : Access, U64 => Try(FileSelection, Unavailable)

Reopen a remembered file as a new read-only grant, after the host checks it is still the file that was remembered.

reopen_directory! : Access, U64 => Try(Selection, Unavailable)

Reopen a remembered folder as a new read-only grant, after the host checks it is still the folder that was remembered.

forget_recent! : Access, U64 => Try({}, Unavailable)

Remove one entry from the recent list. Its grants held this session are not withdrawn. Forgotten when no entry has the key.

remember_file! : Access, Read => Try({}, Unavailable)

Remember a chosen or dropped file, so it is listed by recent! in this and later runs until it is forgotten or withdrawn.

remember_directory! : Access, Read => Try({}, Unavailable)

Remember a chosen folder, as remember_file! remembers a file.

decode_remembered : Dec -> [Err([AccessDenied, Forgotten, Missing, Replaced, Revoked, Unreadable, Unsupported]), Ok({})]
decode_unavailable : Dec -> [AccessDenied, Forgotten, Missing, Replaced, Revoked, Unreadable, Unsupported]
app_data! : Access => Try(ReadWrite, FileErr)

Acquire the private read-write application-data directory granted by the host.

decode_watch_reason : Dec -> [AccessDenied, InvalidCapability, Io, ResourceLimit, Revoked, Unavailable, Unsupported]
decode_reason : Dec -> [AccessDenied, InvalidCapability, InvalidName, Io, ResourceLimit, Revoked, Unavailable]
Choice : [Canceled, Chosen(a)]

The result of acquiring a provisioned selection. Canceling is successful.

Kind : [Directory, File, Other, SymbolicLink]

The kind of one directory entry. Symbolic links are reported, not followed.

Entry : { name : Str, kind : Kind, bytes : [None, Some(U64)] }

One direct child. bytes is present for regular files when metadata is available and absent for directories and other entries.

Reason : [
    AccessDenied,
    InvalidCapability,
    InvalidName,
    InvalidUtf8,
    Io,
    NotDirectory,
    NotFound,
    ResourceLimit,
    Revoked,
    Unavailable,
    Unsupported,
]

A stable, portable category for a filesystem failure.

FileErr : [
    OpenAppDataErr(Reason),
    ListDirectoryErr(Reason),
    OpenReadDirectoryErr(Reason),
    PickDirectoryErr(Reason),
    PickFileErr(Reason),
    ReadFileErr(Reason),
    WatchDirectoryErr(Reason),
    WriteFileErr(Reason),
]

A filesystem failure. The tag identifies the operation that failed, so callers can handle operation-specific failures directly.

Change : [Canceled, Changed(Changes), Gone, Revoked]

What one wait on a watch resolved to. Changed reports a change; the others end the watch, and every later wait answers the same.

  • Changed: what the watch covers changed. names are the names that changed since the previous wait, each once: the direct children of a watched directory that were created, removed, renamed, or written, or a watched database's own name. replaced is set when one of them may now refer to a different file, because a file was renamed over it or it was removed or created; reopen it to read what it names now. overflowed is set when more changed than a wait can name, and then names is incomplete.
  • Canceled: the watch was cancelled, or released, or what it watches was released.
  • Revoked: the grant it was derived from was withdrawn.
  • Gone: the watched directory itself was removed or moved away, so no later change can be reported.

Watch

:= Watch

An opaque, cancellable subscription to changes of a granted directory or database. Changes are coalesced rather than queued: one wait reports every change since the previous wait returned, once writing has paused briefly, so a watch holds no backlog however fast its files are written. It is derived from what it watches, so withdrawing that grant, or releasing what it watches, ends it.

next! : Watch => Change

Wait for the next change. Call from Action.task; exactly one wait may be outstanding, and cancelling wakes it with Canceled.

cancel! : Watch => [AlreadyStopped, Canceled]

Stop this watch. Cancellation is idempotent.

from_resource : Watch -> Watch

Wrap the shared representation, for the platform's own modules that derive a watch, as Sqlite does. An application cannot produce the representation, so this grants nothing.

Selection : { name : Str, directory : Read }

A chosen directory's display name and read authority.

FileSelection : { name : Str, file : Read }

A chosen file's display name and read authority.

FileType : { label : Str, extensions : List(Str), mime_types : List(Str) }

One kind of file the chooser offers. extensions are written without a leading dot, such as "rgstats"; mime_types are full types such as "application/vnd.sqlite3". The host checks a chosen file against the extensions of every type offered, so a file of any other extension is refused with PickFileErr(Unsupported) whichever chooser produced it.

Unavailable : [AccessDenied, Forgotten, Missing, Replaced, Revoked, Unreadable, Unsupported]

Why a remembered file or folder cannot be reopened, or a grant cannot be remembered.

  • AccessDenied: the application may no longer read it.
  • Forgotten: no recent entry has this key, because it was forgotten or the list outgrew its bound.
  • Missing: nothing is at its place any more.
  • Replaced: something else is at its place now: another file renamed over it, or a folder where a file was. It is not what was chosen.
  • Revoked: the grant being remembered was withdrawn.
  • Unreadable: it could not be reached for another reason.
  • Unsupported: only a file or folder a person chose, dropped, or was provisioned can be remembered, not one derived from another grant.
Recent : { key : U64, name : Str, kind : [Directory, File], status : [Available, Unavailable(Unavailable)] }

One file or folder the application remembered, most recent first. key names it for reopen_file!, reopen_directory!, and forget_recent!, and stays the same across restarts. status is what the host found when the list was read: whether it can be reopened now. No path is ever part of an entry.

run : Config(state) -> Program(state)

Construct the program value required by the platform's main module.

adaptive : U32, U32 -> Color

A colour for each appearance, 0xRRGGBB both: light on a light window and dark on a dark one. The host chooses when it paints, so the window follows the system, or Appearance.prefer!, without rendering the application again.

inset : U32 -> Inset

Construct a fixed per-side inset.

px : U32 -> Length

Construct a fixed pixel length.

text : Str -> Elem(a)

Display literal text. It inherits colour and size from its container.

chord : Str -> Elem(a)

Display a key chord, declared as a shortcut declares it (secondary-k), in the spelling of the platform it runs on: ⌘K on macOS and ctrl-K elsewhere, so a hint always names the keys a person presses.

styled_text : TextProps -> Elem(a)

Display text in its own colour, size, weight, and face.

span : SpanProps -> TextSpan

One styled run of rich text: its own colour, ground, weight, underline, or monospace face.

rich_text : RichTextProps -> Elem(a)

Display several styled runs as one text element, which lays out and wraps as one string and is located by the whole of it.

button : ButtonProps(a) -> Elem(a)

Display a controlled button. caption is its visible text and label its semantic locator.

checkbox : CheckboxProps(a) -> Elem(a)

Display a controlled checkbox.

text_input : TextInputProps(a) -> Elem(a)

Display a controlled single-line text editor.

textarea : TextareaProps(a) -> Elem(a)

Display a controlled multiline text editor.

image : ImageProps -> Elem(a)

Render encoded image bytes.

canvas : CanvasProps(a) -> Elem(a)

Paint keyed vector primitives and receive pointer gestures.

row : RowProps, List(Elem(a)) -> Elem(a)

Lay out children horizontally in order.

col : ColProps, List(Elem(a)) -> Elem(a)

Lay out children vertically in order.

panel : PanelProps, List(Elem(a)) -> Elem(a)

Group children in a labelled, bordered vertical surface.

dialog : DialogProps(a), List(Elem(a)) -> Elem(a)

Present one modal surface.

split : SplitProps(a), Elem(a), Elem(a) -> Elem(a)

Lay two panes out beside or above each other, with a divider a person drags or moves with the arrow keys to resize them.

tabs : TabsProps(a) -> Elem(a)

A strip of selectable tabs, each with an optional close button.

drop_target : DropTargetProps(a), List(Elem(a)) -> Elem(a)

Lay children out in a column that accepts files dropped on it, each granted to the application as a read-only file of an accepted type.

popover : PopoverProps(a), Elem(a), List(Elem(a)) -> Elem(a)

Annotate an anchor with a non-modal surface that opens on hover and focus.

tooltip : Elem(a), Str -> Elem(a)

Annotate an element with a short text tooltip, named by that text.

shortcuts : Elem(a), List(Shortcut(a)) -> Elem(a)

Answer key chords anywhere in the window while an element is mounted.

focus_shortcuts : Elem(a), List(Shortcut(a)) -> Elem(a)

Answer key chords only while keyboard focus is inside an element.

request_focus : Elem(a), U64 -> Elem(a)

Focus the first enabled control inside an element once for each new serial.

scroll : ScrollProps(a) -> Elem(a)

Constrain content to the available space and allow scrolling.

virtual_list : VirtualListProps(a) -> Elem(a)

Present fixed-height rows, materializing only the visible range.

virtual_rows : VirtualRowsProps(a) -> Elem(a)

Present count fixed-height rows, producing each on demand for the viewport.

translate : (child -> Elem(child)), (parent -> child), (parent, child -> parent) -> Elem(parent)

Embed a renderer over a smaller part of parent state.

translate_with : (child -> Elem(child)), TranslateConfig(parent, child) -> Elem(parent)

Embed a keyed renderer whose lifetime survives parent renders.

try_translate : (child -> Elem(child)), TryTranslateConfig(parent, child) -> Elem(parent)

Embed a removable child through fallible adapters.

keyed_col : (item -> Elem(item)), ColProps, KeyedColConfig(parent, item) -> Elem(parent)

Adapt a persistent keyed sequence into a native column.

rectangle : CanvasRectangle -> CanvasPrimitive

A filled, optionally stroked and rounded rectangle on a canvas.

ellipse : CanvasEllipse -> CanvasPrimitive

A filled, optionally stroked ellipse on a canvas.

line : CanvasLine -> CanvasPrimitive

A stroked line on a canvas.

canvas_text : CanvasText -> CanvasPrimitive

A single line of text on a canvas, aligned within a box.

Elem

Gui.Elem(a) :: # (opaque)

A declarative UI tree whose event handlers transition application state.

translate : (child -> Elem(child)), (parent -> child), (parent, child -> parent) -> Elem(parent)

Embed a renderer over a smaller part of parent state. Local updates render this child without rebuilding siblings. get reads it; set replaces it. Reconstructing this unkeyed descriptor from its parent starts a fresh mounted lifetime.

translate_with : (child -> Elem(child)), TranslateConfig(parent, child) -> Elem(parent)

Preserve a child's lifetime across parent renders and reordering using a key. Use this when tasks or native interaction state should survive those renders. Keys preserve the lifetime within the surviving owner and native scope. Memoization is opt-in; its input must cover rendering and handler captures.

try_translate : (child -> Elem(child)), TryTranslateConfig(parent, child) -> Elem(parent)

Embed a removable collection entry using a stable key and fallible adapters. Missing projections discard task completions and cannot recreate state.

boundary : (child -> Elem(child)), [None, Some(Key)], Project(parent, child), (parent, child -> Try(parent, [Removed])), (parent -> Action(parent)), [None, Some(child, child -> Bool)] -> Elem(parent)
rectangle : CanvasRectangle -> CanvasPrimitive

A filled, optionally stroked and rounded rectangle on a canvas.

ellipse : CanvasEllipse -> CanvasPrimitive

A filled, optionally stroked ellipse on a canvas.

line : CanvasLine -> CanvasPrimitive

A stroked line on a canvas.

canvas_text : CanvasText -> CanvasPrimitive

A single line of text on a canvas, aligned within a box.

style_of : { ..a, active_bg : Color, align : Align, bg : Color, border_bottom : Inset, border_color : Color, border_left : Inset, border_right : Inset, border_top : Inset, border_width : U32, disabled_bg : Color, disabled_fg : Color, fg : Color, focus_color : Color, font_face : FontFace, font_size : U32, font_weight : U32, gap : U32, grow : Bool, height : Length, hover_bg : Color, justify : Justify, max_height : Length, max_width : Length, min_height : Length, min_width : Length, overflow_x : Overflow, overflow_y : Overflow, padding : U32, padding_bottom : Inset, padding_left : Inset, padding_right : Inset, padding_top : Inset, radius : U32, shadow : U32, shadow_alpha : U32, shadow_color : Color, shadow_y : U32, text_overflow : TextOverflow, width : Length } -> Style
text : Str -> Elem(a)

Display literal text. It inherits colour and size from its container.

chord : Str -> Elem(a)

Display a key chord, declared as a shortcut declares it (secondary-k), in the spelling of the platform it runs on: ⌘K on macOS and ctrl-K elsewhere. It inherits colour and size from its container, and with_style restyles it as it restyles text.

styled_text : TextProps -> Elem(a)

Display text in its own colour, size, weight, and face, without a container element that exists only to carry them.

span : SpanProps -> TextSpan

One run of rich text in its own colour, ground, weight, underline, or monospace face.

rich_text : RichTextProps -> Elem(a)

Display several styled runs as one text element. It lays out, wraps, and clips as one string, and a locator matches the whole of it.

button : ButtonProps(a) -> Elem(a)

Display a controlled button. caption is its visible text and label is its stable semantic locator.

checkbox : CheckboxProps(a) -> Elem(a)

Display a controlled checkbox. A handler must return the state containing the next checked value for the visual state to change.

textarea : TextareaProps(a) -> Elem(a)

Edit controlled multiline text. The application installs the next value returned by on_input; use read_only: True for response viewers.

image : ImageProps -> Elem(a)

Render encoded image bytes without granting the host ambient I/O.

canvas : CanvasProps(a) -> Elem(a)

Paint keyed vector primitives and receive pointer gestures through one captured direct-manipulation route.

text_input : TextInputProps(a) -> Elem(a)

Display a controlled native single-line text editor.

row : RowProps, List(Elem(a)) -> Elem(a)

Lay out children horizontally in order.

col : ColProps, List(Elem(a)) -> Elem(a)

Lay out children vertically in order.

with_style : Elem(a), (Style -> Style) -> Elem(a)

Apply a presentation change to an element. Literal text becomes styled text, and a component boundary passes the change to the root it renders.

label : Elem(a), Str -> Elem(a)

Name an element with a stable semantic locator for specifications and accessibility. Literal text has none.

gap : Elem(a), U32 -> Elem(a)

Space between a container's children.

padding : Elem(a), U32 -> Elem(a)

Inset on every side that has no side of its own.

width : Elem(a), Length -> Elem(a)

The element's width.

height : Elem(a), Length -> Elem(a)

The element's height.

grow : Elem(a), Bool -> Elem(a)

Take the space left over along the parent's layout axis.

bg : Elem(a), Color -> Elem(a)

The background colour.

hover_bg : Elem(a), Color -> Elem(a)

The background while the pointer is over the element.

active_bg : Elem(a), Color -> Elem(a)

The background while the element is pressed.

fg : Elem(a), Color -> Elem(a)

The text colour.

radius : Elem(a), U32 -> Elem(a)

The corner radius.

font_size : Elem(a), U32 -> Elem(a)

The text size; zero selects the native default.

font_weight : Elem(a), U32 -> Elem(a)

The text weight, 100 through 900; zero selects the native default.

shadow : Elem(a), U32 -> Elem(a)

The blur radius of a soft drop shadow; zero paints none.

align : Elem(a), Align -> Elem(a)

Where a container places its children across its layout axis.

justify : Elem(a), Justify -> Elem(a)

How a container distributes its children along its layout axis.

enabled : Elem(a), Bool -> Elem(a)

Whether a button, checkbox, text input, or textarea accepts interaction.

placeholder : Elem(a), Str -> Elem(a)

Text shown by an empty text input or textarea.

read_only : Elem(a), Bool -> Elem(a)

Let a textarea be selected and scrolled but not edited.

axis : Elem(a), ScrollAxis -> Elem(a)

The axes a scroll region moves along.

row_gap : Elem(a), U32 -> Elem(a)

Space held clear at the bottom of each virtual list row inside its row height.

fit : Elem(a), ImageFit -> Elem(a)

How an image's decoded pixels fit its styled bounds.

grayscale : Elem(a), Bool -> Elem(a)

Paint an image without colour.

box_bg : Elem(a), Color -> Elem(a)

A checkbox's unchecked box colour.

box_checked_bg : Elem(a), Color -> Elem(a)

A checkbox's checked box colour.

box_border : Elem(a), Color -> Elem(a)

A checkbox's box border colour.

mark_color : Elem(a), Color -> Elem(a)

A checkbox's check mark colour.

heading : Elem(a), Str -> Elem(a)

A panel's visible heading.

heading_color : Elem(a), Color -> Elem(a)

A panel heading's colour.

on_press : Elem(a), (a, Press => Action(a)) -> Elem(a)

Handle a button press.

on_hover_enter : Elem(a), (a, Hover => Action(a)) -> Elem(a)

Handle the pointer entering an element. A button and a popover report it themselves; any other element is wrapped in a hover region that reports it and presents nothing.

on_hover_exit : Elem(a), (a, Hover => Action(a)) -> Elem(a)

Handle the pointer leaving an element, wrapping it in a hover region exactly as on_hover_enter does.

hover_region : Elem(a), [None, Some(a, Hover => Action(a))], [None, Some(a, Hover => Action(a))] -> Elem(a)
region : Elem(a), (PopoverNode(a) -> PopoverNode(a)) -> Elem(a)

A region of anchor that presents nothing, for the annotations that need no surface. A popover already is one, so it takes them itself.

shortcuts : Elem(a), List(Shortcut(a)) -> Elem(a)

Answer key chords anywhere in the window while elem is mounted. A shortcut declared nearer the focused control wins over one further out; a modal dialog leaves live only the shortcuts declared inside it. A chord that types a character into a focused text field is text, and Tab, Shift-Tab, and Escape belong to the host.

focus_shortcuts : Elem(a), List(Shortcut(a)) -> Elem(a)

Answer key chords only while keyboard focus is inside elem, before any shortcut declared further out.

bind : Elem(a), List(Shortcut(a)), [Window, Focus] -> Elem(a)
request_focus : Elem(a), U64 -> Elem(a)

Move keyboard focus to the first enabled control inside elem, once for each distinct serial: holding the same serial across later renders leaves focus wherever a person has since moved it, and a new serial moves it again. A serial of 0 asks for nothing.

on_check : Elem(a), (a, Check => Action(a)) -> Elem(a)

Handle a checkbox being toggled.

on_change : Elem(a), (a, TextChange => Action(a)) -> Elem(a)

Handle an edit to a text input.

on_submit : Elem(a), (a, TextSubmit => Action(a)) -> Elem(a)

Handle a text input being submitted.

on_input : Elem(a), (a, Input => Action(a)) -> Elem(a)

Handle an edit to a textarea.

on_dismiss : Elem(a), (a, Dismiss => Action(a)) -> Elem(a)

Handle a dialog being dismissed.

on_pointer : Elem(a), (a, CanvasPointer => Action(a)) -> Elem(a)

Handle a pointer gesture on a canvas.

keyed_col : (item -> Elem(item)), ColProps, KeyedColConfig(parent, item) -> Elem(parent)
dialog : DialogProps(a), List(Elem(a)) -> Elem(a)

Present one modal surface, focus its first enabled control, trap keyboard traversal inside it, and restore its opener after dismissal.

popover : PopoverProps(a), Elem(a), List(Elem(a)) -> Elem(a)

Annotate anchor with a surface presenting content beside it. The surface does not block the rest of the window: it opens while the pointer rests on the anchor or keyboard focus is inside it, and Escape closes it.

tooltip : Elem(a), Str -> Elem(a)

Annotate an element with a short text tooltip, named by that text.

split : SplitProps(a), Elem(a), Elem(a) -> Elem(a)

Lay two panes out side by side, or one above the other, with a divider between them that a person drags, or moves with the arrow keys while it has keyboard focus. The size is the application's: on_resize asks for one, and the split shows whatever size it is given next.

tabs : TabsProps(a) -> Elem(a)

A strip of tabs, one of them selected, each with an optional close! button. Selecting or closing one asks the application, which owns the list and the selection.

tab_unit : TabsProps(a), TabItem -> Elem(a)
panel : PanelProps, List(Elem(a)) -> Elem(a)

Group children in a labelled padded, bordered, rounded vertical surface.

drop_target : DropTargetProps(a), List(Elem(a)) -> Elem(a)

Lay children out in a column that accepts files a person drops on it. Each dropped file of an accepted type is granted to the application as a read-only file and delivered to on_drop, with every other item dropped named and refused. The target shows drop_bg and drop_border while files it would accept are dragged over it.

scroll : ScrollProps(a) -> Elem(a)

Constrain content to the available space and allow scrolling.

virtual_list : VirtualListProps(a) -> Elem(a)

Present fixed-height rows while materializing only the visible native range.

virtual_rows : VirtualRowsProps(a) -> Elem(a)

Present count fixed-height rows, building each with render_row only while it is near the viewport. The list is its own render boundary: when scrolling brings unbuilt rows near, the platform renders the list alone, from the renderer's most recent render_row, without rendering its owner. The boundary is transparent, so an action raised by a row or by on_range belongs to the list's owner, exactly as if the rows had been built there.

lift : Elem(child), (parent -> child), (parent, child -> parent) -> Elem(parent)

Adapt an already-built child tree to parent state.

lift_with : Elem(child), Project(parent, child), (parent, child -> Try(parent, [Removed])), (Action(child), parent, (Action(parent) -> Work) -> Work) -> Elem(parent)
lift_split : Elem(a) -> { shell : Elem(a), children : List(Elem(a)) }
lift_shell : Elem(child), Project(parent, child), (parent, child -> Try(parent, [Removed])), (Action(child), parent, (Action(parent) -> Work) -> Work) -> Elem(parent)
lift_provider : RowProvider(child), Project(parent, child), (parent, child -> Try(parent, [Removed])), (Action(child), parent, (Action(parent) -> Work) -> Work) -> RowProvider(parent)
adapt_event : (child, event => Action(child)), parent, event, Project(parent, child), (Action(child), parent, (Action(parent) -> Work) -> Work) -> Action(parent)
inspect : Elem(a) -> [
    Component(BoundComponent(a)),
    ActionButton(ButtonNode(a)),
    Checkbox(CheckboxNode(a)),
    Textarea(TextareaNode(a)),
    Image(ImageNode),
    Canvas(CanvasNode(a)),
    Column({ children : List(Elem(a)), props : Frame }),
    KeyedColumn({ base_revision : U64, children : List(Elem(a)), full : Box({} => { children : List(Elem(a)), keys : List(Key) }), keys : List(Key), operations : List(KeyedOperation), props : Frame, revision : U64 }),
    Dialog({ children : List(Elem(a)), props : DialogNode(a) }),
    Popover({ children : List(Elem(a)), props : PopoverNode(a) }),
    Panel({ children : List(Elem(a)), props : PanelNode }),
    Row({ children : List(Elem(a)), props : Frame }),
    Scroll(ScrollNode(a)),
    VirtualList(VirtualListNode(a)),
    TextInput(TextInputNode(a)),
    Split({ children : List(Elem(a)), props : SplitNode(a) }),
    DropTarget({ children : List(Elem(a)), props : DropTargetNode(a) }),
    StyledText(TextNode),
    Chord(ChordNode),
    Text(Str),
]

Reveal an element descriptor. This supports platform-side traversal and libraries that transform element trees.

KeyedOperation : [KeyedInsert(Key, Placement), KeyedMove(Key, Placement), KeyedRemove(Key), KeyedSet(Key)]

KeyedColConfig

:= {
    key : Key,
    get : parent -> KeyedSeq(item),
    set : parent, KeyedSeq(item) -> parent,
    on_delegate : parent, Key -> Action(parent) ?? |parent, _key| Action.update(parent),
}

Adapt a persistent keyed sequence into a native column. Every item is a component boundary owned by its complete Key; item actions project by key, so reordering never changes their target and removal cannot recreate one.

BoundComponent

:= {
    key : [None, Some(Key)],
    render : a, (Elem(a) -> Work) -> Work,
    exists : a, (Bool -> Work) -> Work,
    remember : [None, Some(a, (Box(a, (Bool -> Work) -> Work) -> Work) -> Work)],
    transparent : Bool,
}

Platform representation of a local boundary. Applications construct one with translate, translate_with, or try_translate.

TranslateConfig

:= {
    key : Key,
    get : parent -> child,
    set : parent, child -> parent,
    on_delegate : parent -> Action(parent) ?? Action.update,
    memo : [None, Some(child, child -> Bool)] ?? None,
}

Connect a child renderer to parent state and give it a stable lifetime. Start with key, get, and set; add policies only when needed. get reads the child; set replaces it while preserving other parent data. on_delegate receives the proposed parent and defaults to Action.update; returning Action.none() rejects the whole proposal. memo defaults to None. A comparator receives saved and incoming child states: True promises that both the rendered UI and captured handlers remain equivalent. Retaining that comparison snapshot can require cloning during subsequent updates.

TryTranslateConfig

:= {
    key : Key,
    get : parent -> Try(child, [Removed]),
    set : parent, child -> Try(parent, [Removed]),
    on_delegate : parent -> Action(parent) ?? Action.update,
    memo : [None, Some(child, child -> Bool)] ?? None,
}

Connect a removable child by stable identity, not a captured list position. Omit the element when the child is already absent. get and set return Err(Removed) when the projection no longer exists. A rejected setter discards the whole action before delegation or task launch. Preserve unrelated parent data and never recreate a removed child in set. on_delegate and memo follow the same contracts as TranslateConfig.

Project : parent, (Try(child, [Removed]) -> Work) -> Work

Frame

:= { label : Str, style : Style }

The semantic locator and presentation shared by row, col, and keyed_col.

DialogNode

:= { label : Str, style : Style, on_dismiss : a, Dismiss => Action(a) }

Platform representation of a modal dialog.

Placement : [Above, Below, Start, End]

Where a popover's surface sits against its anchor: over it, under it, before it, or after it. The surface moves to the opposite side when the window has no room for it on the one asked for.

PopoverNode

:= {
    label : Str,
    placement : Placement,
    delay_ms : U32,
    on_hover_enter : [None, Some(a, Hover => Action(a))],
    on_hover_exit : [None, Some(a, Hover => Action(a))],
    shortcuts : List(Binding(a)),
    focus_serial : U64,
    style : Style,
}

Platform representation of a popover. Its first child is the anchor and any others are the surface's content. A popover with no content is a region of its anchor: it reports the pointer entering and leaving it, answers its keyboard shortcuts, and asks for focus, and presents nothing.

Shortcut : { keys : Str, on_press : a, Key => Action(a) }

A key chord and what pressing it does. keys names modifiers and a key joined by -, such as ctrl-k, shift-down, or secondary-s, where secondary is Ctrl on Linux and Windows and Cmd on macOS.

Binding : { keys : Str, scope : [Window, Focus], on_press : a, Key => Action(a) }

Platform representation of one shortcut and when it is live: while its region is mounted, or only while keyboard focus is inside the region.

PanelNode

:= { label : Str, style : Style, heading : Str, heading_size : U32, heading_weight : U32, heading_color : Color }

Platform representation of a headed surface.

ButtonNode

:= {
    caption : Str,
    label : Str,
    role : ButtonRole,
    enabled : Bool,
    on_press : a, Press => Action(a),
    on_hover_enter : [None, Some(a, Hover => Action(a))],
    on_hover_exit : [None, Some(a, Hover => Action(a))],
    style : Style,
}

Platform representation of a button. caption is its visible text and label is its stable semantic locator.

ButtonRole : [Button, Tab, SelectedTab]

What a pressable control is to a person and to a locator: a button, or one tab of a tab strip, selected or not.

SplitAxis : [Horizontal, Vertical]

The direction a split lays its two panes out in. Horizontal puts them side by side with an upright divider between; Vertical stacks them.

SplitSide : [Start, End]

Which of a split's two panes its size belongs to: the first, or the second. The other pane takes the space that is left.

SplitNode

:= {
    label : Str,
    axis : SplitAxis,
    side : SplitSide,
    size : U32,
    min : U32,
    max : U32,
    collapsible : Bool,
    collapsed : Bool,
    thickness : U32,
    on_resize : a, Resize => Action(a),
    keys : List(Shortcut(a)),
    style : Style,
}

Platform representation of a split: its two panes are its children, and it draws the divider between them. It carries the sized pane's extent, its bounds, and whether it may and does collapse, so the host can turn a drag into the size it asks for, and the keys its divider answers while the divider holds keyboard focus. style dresses the divider: bg and its hover, pressed, and focus colours; its size fields size the split.

TabItem : { key : Str, title : Str, closable : Bool }

One tab of a tab strip: the key its events carry, the caption it shows, which also names it, and whether it offers a close button.

DropTargetNode

:= {
    label : Str,
    types : List(FileType),
    on_drop : a, Drop => Action(a),
    drop_bg : Color,
    drop_border : Color,
    style : Style,
}

Platform representation of a drop target: a column whose children are laid out as col lays them out, which accepts files dropped on it. It carries the file types it accepts, the colours it shows while files it would accept are dragged over it, and the handler a drop is delivered to.

TextInputNode

:= {
    label : Str,
    value : Str,
    placeholder : Str,
    enabled : Bool,
    on_change : a, TextChange => Action(a),
    on_submit : a, TextSubmit => Action(a),
    style : Style,
}

Platform representation of a single-line text editor.

ScrollAxis : [Both, Horizontal, Vertical]

The axes a scroll region moves along.

ScrollNode

:= { axis : ScrollAxis, content : Elem(a), label : Str, style : Style }

Platform representation of a scrollable region.

VirtualListItem

:= { content : Elem(a), key : U64 }

One stable row in a virtual list. key identifies the row independently of its current index, while content is an ordinary element tree.

VirtualListNode

:= { items : List(VirtualListItem(a)), label : Str, row_height : U32, row_gap : U32, style : Style, provider : [None, Some(RowProvider(a))] }

Platform representation of a viewport-driven, fixed-height list. A list built by virtual_list carries its rows in items; one built by virtual_rows carries a provider instead and no items.

RowAlign : [Start, Center, End, Nearest]

Where a list places a row it is asked to bring into view: at the leading edge, in the middle, at the trailing edge, or wherever moves it least — not at all when the row is already in view.

ScrollRequest : { row : U64, align : RowAlign, serial : U64 }

A request to bring row into view at align. The list moves once for each distinct serial: holding the same request across later renders leaves a person's own scrolling alone, and a new serial moves the list again, even to the same row.

RowProvider

:= {
    count : U64,
    render_row : U64 -> Elem(a),
    row_key : U64 -> U64,
    scroll_to : [None, Some(ScrollRequest)],
    on_range : [None, Some(a, VisibleRows => Action(a))],
}

Platform representation of rows produced on demand.

CheckboxNode

:= {
    label : Str,
    checked : Bool,
    enabled : Bool,
    on_change : a, Check => Action(a),
    box_bg : Color,
    box_checked_bg : Color,
    box_border : Color,
    mark_color : Color,
    style : Style,
}

Platform representation of a checkbox.

TextareaNode

:= {
    label : Str,
    value : Str,
    placeholder : Str,
    enabled : Bool,
    read_only : Bool,
    on_input : a, Input => Action(a),
    style : Style,
}

Platform representation of a multiline text editor.

ImageFormat : [Bmp, Gif, Jpeg, Png, Svg, Tiff, Webp]

Encoded image formats accepted by the native image decoder.

ImageFit : [Contain, Cover, Fill, None, ScaleDown]

How decoded pixels fit the image's styled bounds.

ImageNode

:= { label : Str, bytes : List(U8), format : ImageFormat, fit : ImageFit, grayscale : Bool, style : Style }

Platform representation of an encoded in-memory image.

CanvasEllipse

:= { key : U64, label : Str, x : I32, y : I32, width : U32, height : U32, fill : Color, stroke : Color ?? Default, stroke_width : U32 ?? 0 }

A retained drawing primitive. Keys must be non-zero and unique within a canvas. Primitives are painted in list order and hit-tested in reverse.

CanvasText

:= { key : U64, label : Str, x : I32, y : I32, width : U32, value : Str, color : Color, size : U32 ?? 12, align : CanvasTextAlign ?? Start }

A single line of text set in the box from x to x + width, with its top at y and a line size * 5 / 4 pixels tall. align places the text within the box; text wider than the box is not clipped. Text is painted but never hit-tested, so a label drawn over a shape leaves the shape as the pointer's target.

CanvasPrimitive : [
    Ellipse(CanvasEllipse),
    Line(CanvasLine),
    Rectangle(CanvasRectangle),
    Text(CanvasText),
]

CanvasNode

:= {
    label : Str,
    primitives : List(CanvasPrimitive),
    on_pointer : a, CanvasPointer => Action(a),
    on_hover : [None, Some(a, CanvasHover => Action(a))],
    on_wheel : [None, Some(a, CanvasWheel => Action(a))],
    on_size : [None, Some(a, CanvasSize => Action(a))],
    style : Style,
}

Platform representation of a native retained canvas. Coordinates are integer logical pixels, which makes semantic gestures and deterministic rendering agree.

TextNode

:= { value : Str, style : Style, spans : List(TextSpan) }

Platform representation of text set in its own colour, size, weight, and face. Only the typographic fields of style apply to a string. spans is empty for text of one style; otherwise value is the spans' texts in order, and each span restyles its own part of it.

ChordNode

:= { keys : Str, style : Style }

Platform representation of a key chord shown as text. keys is the chord as a shortcut declares it; the host spells it as the person presses it.

TextSpan : { text : Str, fg : Color, bg : Color, font_weight : U32, underline : Bool, monospace : Bool }

One styled run of rich text: its text, and what it sets over the element's own type. Default colours and weight 0 keep the element's.

SpanProps

:= {
    text : Str,
    fg : Color ?? Default,
    bg : Color ?? Default,
    font_weight : U32 ?? 0,
    underline : Bool ?? False,
    monospace : Bool ?? False,
}

Properties for span. Only text is required.

RichTextProps

:= {
    spans : List(TextSpan),
    fg : Color ?? Default,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    font_face : FontFace ?? Default,
}

Properties for rich_text: its spans, and the type every span starts from.

ColProps

:= {
    label : Str ?? "",
    gap : U32 ?? 8,
    padding : U32 ?? 0,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Default,
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Default,
    border_width : U32 ?? 0,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 0,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Visible,
    overflow_y : Overflow ?? Visible,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for col. label is an optional stable semantic locator. The remaining fields control the column's native layout and presentation.

RowProps

:= {
    label : Str ?? "",
    gap : U32 ?? 8,
    padding : U32 ?? 0,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Default,
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Default,
    border_width : U32 ?? 0,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 0,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Visible,
    overflow_y : Overflow ?? Visible,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for row. label is an optional stable semantic locator. The remaining fields control the row's native layout and presentation.

DialogProps

:= {
    label : Str,
    on_dismiss : a, Dismiss => Action(a),
    gap : U32 ?? 16,
    padding : U32 ?? 24,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Px(520),
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Rgb(0x212f37),
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Rgb(0xeeeeea),
    border_color : Color ?? Rgb(0x48666b),
    border_width : U32 ?? 1,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 8,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Visible,
    overflow_y : Overflow ?? Visible,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for a modal dialog. label is its stable semantic name and on_dismiss handles Escape. Dialogs center above an input-blocking scrim.

PopoverProps

:= {
    label : Str,
    placement : Placement ?? Below,
    delay_ms : U32 ?? 500,
    on_hover_enter : [None, Some(a, Hover => Action(a))] ?? None,
    on_hover_exit : [None, Some(a, Hover => Action(a))] ?? None,
    gap : U32 ?? 4,
    padding : U32 ?? 8,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Px(360),
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Rgb(0x0f1b21),
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Rgb(0xeeeeea),
    border_color : Color ?? Rgb(0x48666b),
    border_width : U32 ?? 1,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 6,
    font_size : U32 ?? 14,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 12,
    shadow_y : U32 ?? 4,
    shadow_color : Color ?? Rgb(0x000000),
    shadow_alpha : U32 ?? 60,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Visible,
    overflow_y : Overflow ?? Visible,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for popover. label is the surface's stable semantic name, its locator as a tooltip. The surface opens delay_ms after the pointer comes to rest on the anchor, and at once when keyboard focus enters the anchor; it closes when both have left, or on Escape. The style fields dress the surface, never the anchor.

PanelProps

:= {
    label : Str,
    heading : Str ?? "",
    heading_size : U32 ?? 0,
    heading_weight : U32 ?? 0,
    heading_color : Color ?? Default,
    gap : U32 ?? 8,
    padding : U32 ?? 16,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Default,
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Rgb(0x48666b),
    border_width : U32 ?? 1,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 8,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Visible,
    overflow_y : Overflow ?? Visible,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for panel. Panels are padded, bordered, rounded vertical surfaces by default, and carry a stable semantic label.

SplitProps

:= {
    label : Str,
    axis : SplitAxis ?? Horizontal,
    side : SplitSide ?? Start,
    size : U32,
    min : U32 ?? 0,
    max : U32 ?? 16384,
    step : U32 ?? 16,
    collapsible : Bool ?? False,
    collapsed : Bool ?? False,
    on_resize : a, Resize => Action(a),
    thickness : U32 ?? 6,
    color : Color ?? Rgb(0x2a3a40),
    hover_color : Color ?? Rgb(0x48666b),
    active_color : Color ?? Rgb(0x5fb3a1),
    focus_color : Color ?? Default,
    width : Length ?? Fill,
    height : Length ?? Fill,
    grow : Bool ?? True,
}

Properties for split. label names the divider, its locator as a separator. size is the extent in logical pixels of the pane on side, held by the application and kept within min and max; the other pane takes the rest. Dragging the divider, or the arrow keys while it has keyboard focus, ask for a new size through on_resize, step pixels a key. Home and End ask for the bounds. A collapsible pane is hidden while collapsed, and stays mounted with its state: Enter on the divider toggles it, and a drag that leaves less than half of min asks for it.

TabsProps

:= {
    label : Str,
    tabs : List(TabItem),
    selected : Str,
    on_select : a, Tab => Action(a),
    on_close : a, Tab => Action(a),
    width : Length ?? Fill,
    gap : U32 ?? 2,
    font_size : U32 ?? 13,
    font_face : FontFace ?? Default,
    max_tab_width : U32 ?? 220,
    fg : Color ?? Rgb(0x9fb0ad),
    selected_fg : Color ?? Rgb(0xeeeeea),
    bg : Color ?? Default,
    selected_bg : Color ?? Rgb(0x1b2a30),
    hover_bg : Color ?? Rgb(0x16242a),
    accent : Color ?? Rgb(0x5fb3a1),
    border_color : Color ?? Rgb(0x2a3a40),
    focus_color : Color ?? Default,
}

Properties for tabs. label names the strip. Each tab is a control named by its title; selected is the key of the tab shown as chosen. Pressing a tab, or Left, Right, Home, and End while keyboard focus is in the strip, choose one through on_select; a closable tab's close button, or Delete, ask to close it through on_close.

DropTargetProps

:= {
    label : Str,
    types : List(FileType),
    on_drop : a, Drop => Action(a),
    drop_bg : Color ?? Rgb(0x1b2a30),
    drop_border : Color ?? Rgb(0x5fb3a1),
    gap : U32 ?? 8,
    padding : U32 ?? 0,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Default,
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Default,
    border_width : U32 ?? 0,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 0,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Visible,
    overflow_y : Overflow ?? Visible,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for drop_target. label names the target, its locator as a drop target. types are the kinds of file it accepts, as pick_file! offers them; an empty list accepts every file. on_drop receives the files a person drops on it, each granted to the application as a read-only file, and names everything else that was dropped. While files it would accept are dragged over it, its ground becomes drop_bg and its border drop_border. The remaining fields lay it out as col does.

ButtonProps

:= {
    caption : Str,
    label : Str,
    enabled : Bool ?? True,
    on_press : a, Press => Action(a),
    on_hover_enter : [None, Some(a, Hover => Action(a))] ?? None,
    on_hover_exit : [None, Some(a, Hover => Action(a))] ?? None,
    gap : U32 ?? 8,
    padding : U32 ?? 8,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Rgb(0x315469),
    hover_bg : Color ?? Rgb(0x3e6a83),
    active_bg : Color ?? Rgb(0x274453),
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Default,
    border_width : U32 ?? 0,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 6,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Visible,
    overflow_y : Overflow ?? Visible,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for action_button. caption is visible text and label is its stable semantic name. Disabled buttons remain visible but cannot be focused or dispatch presses. Visual fields use the same native style vocabulary as layout controls.

TextInputProps

:= {
    label : Str,
    value : Str,
    placeholder : Str ?? "",
    enabled : Bool ?? True,
    on_change : a, TextChange => Action(a),
    on_submit : a, TextSubmit => Action(a),
    gap : U32 ?? 8,
    padding : U32 ?? 8,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Px(38),
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Rgb(0x162a33),
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Rgb(0x48666b),
    border_width : U32 ?? 1,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 6,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Clip,
    overflow_y : Overflow ?? Clip,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for a controlled single-line text field. label is its stable semantic and accessibility name, value is authoritative application state, and placeholder is an empty-field hint. Committed edits deliver the complete value to on_change; Enter delivers it to on_submit.

ScrollProps

:= {
    axis : ScrollAxis ?? Vertical,
    content : Elem(a),
    label : Str,
    gap : U32 ?? 8,
    padding : U32 ?? 0,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Default,
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Default,
    border_width : U32 ?? 0,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 0,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Visible,
    overflow_y : Overflow ?? Visible,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

VirtualListProps

:= {
    items : List(VirtualListItem(a)),
    label : Str,
    row_height : U32,
    row_gap : U32 ?? 0,
    gap : U32 ?? 8,
    padding : U32 ?? 0,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Default,
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Default,
    border_width : U32 ?? 0,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 0,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Visible,
    overflow_y : Overflow ?? Visible,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for a viewport-driven, fixed-height list. Only rows intersecting the native viewport are materialized as GPUI elements.

VirtualRowsProps

:= {
    label : Str,
    row_height : U32,
    count : U64,
    render_row : U64 -> Elem(a),
    row_key : U64 -> U64 ?? |index| index,
    scroll_to : [None, Some(ScrollRequest)] ?? None,
    on_range : [None, Some(a, VisibleRows => Action(a))] ?? None,
    row_gap : U32 ?? 0,
    gap : U32 ?? 8,
    padding : U32 ?? 0,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Default,
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Default,
    border_width : U32 ?? 0,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 0,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Visible,
    overflow_y : Overflow ?? Visible,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for a fixed-height list of count rows produced on demand. render_row is called only for the rows near the viewport, so the cost of a render follows the rows on screen rather than count.

CheckboxProps

:= {
    label : Str,
    checked : Bool,
    enabled : Bool ?? True,
    on_change : a, Check => Action(a),
    box_bg : Color ?? Default,
    box_checked_bg : Color ?? Default,
    box_border : Color ?? Default,
    mark_color : Color ?? Default,
    gap : U32 ?? 8,
    padding : U32 ?? 0,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Default,
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Default,
    border_width : U32 ?? 0,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 0,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Visible,
    overflow_y : Overflow ?? Visible,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for checkbox. label is both visible text and the stable semantic name used by specifications. on_change receives the requested checked state. The common visual fields mirror Style.Style; defaults let a record literal name only the properties it changes.

TextareaProps

:= {
    label : Str,
    value : Str,
    placeholder : Str ?? "",
    enabled : Bool ?? True,
    read_only : Bool ?? False,
    on_input : a, Input => Action(a),
    gap : U32 ?? 8,
    padding : U32 ?? 8,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Fill,
    height : Length ?? Px(160),
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Rgb(0x10252b),
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Rgb(0x48666b),
    border_width : U32 ?? 1,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 6,
    font_size : U32 ?? 15,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Scroll,
    overflow_y : Overflow ?? Scroll,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for a controlled multiline editor. label is its stable semantic name. value remains application-owned; every edit delivers the complete requested value to on_input. Read-only editors expose and scroll text without dispatching edits.

ImageProps

:= {
    label : Str,
    bytes : List(U8),
    format : ImageFormat,
    fit : ImageFit ?? Contain,
    grayscale : Bool ?? False,
    gap : U32 ?? 0,
    padding : U32 ?? 0,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Default,
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Default,
    border_width : U32 ?? 0,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 0,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Clip,
    overflow_y : Overflow ?? Clip,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Properties for an encoded in-memory image. Bytes come from explicit application data or a capability operation; the host never resolves a path or URL. label is the stable semantic name.

CanvasProps

:= {
    label : Str,
    primitives : List(CanvasPrimitive),
    on_pointer : a, CanvasPointer => Action(a),
    on_hover : [None, Some(a, CanvasHover => Action(a))] ?? None,
    on_wheel : [None, Some(a, CanvasWheel => Action(a))] ?? None,
    on_size : [None, Some(a, CanvasSize => Action(a))] ?? None,
    width : Length ?? Fill,
    height : Length ?? Fill,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Rgb(0xffffff),
    border_color : Color ?? Default,
    border_width : U32 ?? 0,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 0,
}

Properties for a native retained canvas. Coordinates are integer logical pixels, which makes semantic gestures and deterministic rendering agree.

TextProps

:= {
    value : Str,
    fg : Color ?? Default,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    font_face : FontFace ?? Default,
}

Properties for styled_text. A string is the only thing a typographic step is about, so these are the type fields alone: a typographic step costs no container, and none of a container's layout is implied.

Action

:= {
    value : [NoChange, Refresh, Update(a), Delegate(a), Deferred(Box(Box(Box(Action(a)) -> Work) -> Work)), Task({ key : Str, pending : a, run : Box(Box(Box(Box(a), Box(Box(Action(a)) -> Work) -> Work) -> Work) -> Work) }), Cancel({ key : Str, state : a })],
    levels : U64,
}

What an event handler asks the platform to do next.

none : () -> Action(a)

Leave state and the displayed UI unchanged.

refresh : () -> Action(a)

Platform action rendering the originating boundary again against the state it already has. Its ancestors' memo snapshots stay valid, because no state changed; only the boundary's own render inputs from the host did.

update : a -> Action(a)

Request a new state for this render boundary. Derive it from the handler's prev_state, not a state snapshot captured by the renderer.

delegate : a -> Action(a)

Propose a child state to the nearest translation's parent policy. The policy may accept, revise, or reject the whole proposed change.

task : { pending : a, run : () => result, resolve : a, result -> Action(a) } -> Action(a)

Accept pending before running run on a worker. resolve receives the state immediately before completion (prev_state) and the worker result. Capture only the request data needed by run; derive the completion action from prev_state so intervening edits survive. Removing the owning component cancels the task: its completion is never delivered, and a capability wait it is blocked in is interrupted.

keyed_task : { key : Str, pending : a, run : () => result, resolve : a, result -> Action(a) } -> Action(a)

A task that supersedes the owning component's previous task with the same non-empty key. The superseded task is cancelled: its completion is never delivered, a query, watch, or timer wait it is blocked in is interrupted, and if it has not started it never runs. Keys are scoped to the component that accepts the task, so two components may use the same key.

cancel : a, Str -> Action(a)

Install state and cancel the owning component's task with this key, as a newer task with that key would. Cancelling a key with no task in flight only installs state.

deferred : ((Action(a) -> Work) -> Work) -> Action(a)

Platform helper deferring action adaptation onto the work executor. This is not an asynchronous task; application I/O belongs in task.

resolve_work! : Action(a), (Action(a) -> Work) -> Work

Platform helper resolving deferred adapters before applying an action.

completion : (a, (Action(a) -> Work) -> Work) -> Box(Completion(a))

Platform helper packaging a typed completion for the work executor.

worker : ((Box(Completion(a)) -> Work) -> Work) -> Box(Worker(a))

Platform helper packaging a worker continuation. Applications use task.

complete_work! : Box(Completion(a)), a, (Action(a) -> Work) -> Work

Platform helper delivering a completion against the supplied current state.

worker_work! : Box(Worker(a)), (Box(Completion(a)) -> Work) -> Work

Platform helper running a worker and forwarding its completion.

inspect : Action(a) -> [NoChange, Refresh, Update(a), Delegate(a), Deferred(Box(Box(Box(Action(a)) -> Work) -> Work)), Task({ key : Str, pending : a, run : Box(Box(Box(Box(a), Box(Box(Action(a)) -> Work) -> Work) -> Work) -> Work) }), Cancel({ key : Str, state : a })]

Reveal the transition for platform dispatch; constructing it has no effect.

owner_levels : Action(a) -> U64

Platform delegation depth used to find the boundary accepting an action.

with_levels : Action(a), U64 -> Action(a)

Platform helper preserving delegation depth through deferred adapters.

lift : Action(child), parent, (parent -> child), (parent, child -> parent) -> Action(parent)

Adapt a child action to parent state using a getter and setter. An adapter has no component lifetime and does not consume delegation.

through_boundary : Action(child), parent, (parent -> child), (parent, child -> parent), (parent -> Action(parent)) -> Action(parent)

Platform adapter that lets the enclosing boundary handle delegation.

adapt : Action(child), parent, (parent -> child), (parent, child -> parent), [None, Some(parent -> Action(parent))] -> Action(parent)

Platform adapter shared by lift and through_boundary.

adapt_worker : Box(Worker(child)), Project(parent, child), (parent, child -> Try(parent, [Removed])), [None, Some(parent -> Action(parent))] -> Box(Worker(parent))

Platform helper projecting completion-time state before resolving a child task.

adapt_work! : Action(child), parent, Project(parent, child), (parent, child -> Try(parent, [Removed])), [None, Some(parent -> Action(parent))], (Action(parent) -> Work) -> Work

Platform adapter executing projection and setter work without recursive calls.

Completion : Box(a), Box(Box(Action(a)) -> Work) -> Work

Platform continuation receiving state at completion delivery. Applications supply the ordinary resolve callback in task instead.

Worker : Box(Box(Completion(a)) -> Work) -> Work

Platform worker continuation producing a completion for the UI thread.

Project : parent, (Try(child, [Removed]) -> Work) -> Work

Platform projection that can report a removed child without recursing.

Program

:= Config(state)

The value an application's main provides.

run : Config(state) -> Program(state)

Construct the program value required by the platform's main module.

start! : Program(state) => {}

Mount a program in the native host and begin event dispatch.

Access : Access

The authority this application was started with. Every acquisition takes one, and there is no way to produce one, so an application holds exactly the authority it was handed and a library holds exactly what it was passed.

Keep it in your state if you acquire anything after the first frame; task closures need it where they run.

Config

:= {
    init : Access -> state,
    render : state -> Elem(state),
    window : WindowProps ?? {},
    on_open : [None, Some(state => Action(state))] ?? None,
}

Initial application data, renderer, optional native window properties, and what the application does as its window opens.

init takes the application's authority rather than being a plain value, because that is the only place it can enter an application from.

on_open runs once, after the first state is shown and before any input, exactly as an event handler runs: it may act, and the action it returns is applied. It is how an application acquires what its first screen shows, such as the files it remembered, without waiting for a person to ask.

WindowProps

:= {
    title : Str ?? "Roc GUI",
    width : U32 ?? 480,
    height : U32 ?? 240,
    background : Color ?? Default,
    foreground : Color ?? Default,
}

Initial native-window identity and logical size. The window remains resizable; these values select its first centered bounds.

Access

Gui.Access :: # (opaque)

The capability from which an application acquires host resources.

mint : Access -> Access

Called once, by Program.start!, at the root of the application. The argument cannot be produced outside the platform.

pick_directory! : Access => Try(Choice(Selection), FileErr)

Acquire the read-only project grant provisioned by the host. This does not display trusted UI; interactive hosts source the grant from trusted selection. Without a provisioned grant it returns AccessDenied.

pick_file! : Access, List(FileType) => Try(Choice(FileSelection), FileErr)

Acquire a read-only grant for one file the person chooses in the operating system's file chooser, offering only types. Canceling is Ok(Canceled). The handle reads that file and nothing beside it.

recent! : Access => List(Recent)

The files and folders this application remembered, most recent first, each checked now against what is at its place. The host keeps the list, outside the application's own storage, so it survives a restart.

reopen_file! : Access, U64 => Try(FileSelection, Unavailable)

Reopen a remembered file as a new read-only grant. The host first checks that the file at its place is still the one remembered, and answers why not when it is missing, replaced, or no longer readable.

reopen_directory! : Access, U64 => Try(Selection, Unavailable)

Reopen a remembered folder as a new read-only grant, checked as reopen_file! checks a file.

forget_recent! : Access, U64 => Try({}, Unavailable)

Remove one entry from the recent list, so it is not offered again.

remember_file! : Access, Read => Try({}, Unavailable)

Remember a file a person chose or dropped, so a later run can reopen it from recent! without asking again. Only the application's root may remember: a library handed the file can read it, but not keep it.

remember_directory! : Access, Read => Try({}, Unavailable)

Remember a folder a person chose, as remember_file! remembers a file.

app_data! : Access => Try(ReadWrite, FileErr)

Acquire the private read-write application-data directory granted by the host.

assets! : Access, StoreConfig => Try(Store, AssetErr)

Open a store over the application's shipped assets. Assets describes the configuration and the refusals.

audio! : Access => Try(Output, AudioErr)

Acquire an output handle for ordinary mixer playback.

clipboard! : Access => Try(Handle, ClipboardErr)

Acquire the clipboard authority granted by the host.

device! : Access => Try(Grant, DeviceErr)

Acquire only the HID authority configured by the host.

http! : Access => Try(Client, HttpErr)

Acquire the network authority explicitly granted by --host-cap-http-origin.

process! : Access => Try(Grant, ProcessErr)

Acquire the process authority explicitly granted with --host-cap-process=local-shell|test-program.

system_monitor! : Access => Try(Sampler, SystemErr)

Acquire the system-observation authority granted by the host.

tcp_connect! : Access => Try(TcpStream, TcpErr)

Connect to the exact endpoint supplied with --host-cap-tcp.

Key

:= Digest

A stable name for a component across parent renders and reordering. Use a string literal for a fixed component and id for a collection entry. Keys must be unique within the same owner and container scope. Keep the key attached to the logical item, rather than its position in a list.

from_str : Str -> Key

Construct a key from a computed name. Store it with the item and reuse it.

from_quote : Str -> Try(Key, [BadQuotedBytes(Str)])

Support string literals such as key: "sidebar".

id : U64 -> Key

Construct a numeric key. id(7) is distinct from the string key "7".

is_eq : Key, Key -> Bool

Compare complete key identities.

to_bytes : Key -> List(U8)

Return the full 32-byte digest used by the platform's identity protocol.

Index

Gui.Index(a) :: # (opaque)

A persistent collection addressed by stable U64 identifiers. Use ordinary lists for small collections; use an Index when replacing one entry in a large, shared collection would otherwise copy the list. Keep display order separately. Missing entries return Err(Missing). Older versions remain readable.

A change copies at most sixteen radix branches, irrespective of unrelated live entries. Leaves retain the remaining key bits and split only when keys collide; distinct entries do not each need a sixteen-level chain of unary branches. Keep branch children boxed so list elements remain pointer-sized. Storing the recursive union inline makes persistent branch updates copy substantially more data; nested-hover-grid/specs/reset-1000.scm guards this scaling path.

empty : () -> Index(a)

An index containing no entries.

get : Index(a), U64 -> Try(a, [Missing])

Look up an identifier, returning Err(Missing) if it is absent.

set : Index(a), U64, a -> Index(a)

Insert or replace an entry while preserving earlier versions of the index.

set_child : List(Box(Index(a))), U64, a -> Index(a)

Implementation helper replacing the radix branch selected by the key.

remove : Index(a), U64 -> Index(a)

Remove an entry. An absent identifier leaves the contents unchanged.

KeyedSeq

Gui.KeyedSeq(value) :: # (opaque)

A persistent ordered collection keyed by the platform's complete Key digest.

empty : () -> KeyedSeq(value)
revision : KeyedSeq(value) -> U64

Current committed collection revision.

last_transition : KeyedSeq(value) -> Transition(value)

The semantic journal that produced the current revision.

transition_from : KeyedSeq(value), U64 -> Try(Transition(value), [StaleRevision({ actual : U64, requested : U64 })])

Read the last journal only when it directly follows the supplied base.

record : KeyedSeq(value), List(Edit(value)) -> KeyedSeq(value)
last_visits : KeyedSeq(value) -> U64

Exact order-tree nodes visited by the last structural operation.

len : KeyedSeq(value) -> U64
get : KeyedSeq(value), Key -> Try(value, Error)
to_list : KeyedSeq(value) -> List({ key : Key, value : value })
insert_before : KeyedSeq(value), Key, value, Placement -> Try(KeyedSeq(value), Error)
remove_raw : KeyedSeq(value), Key -> Try(KeyedSeq(value), Error)
remove : KeyedSeq(value), Key -> Try(KeyedSeq(value), Error)
set_raw : KeyedSeq(value), Key, value -> Try(KeyedSeq(value), Error)
set_local : KeyedSeq(value), Key, value -> Try(KeyedSeq(value), Error)

Replace an item's value for an already-mounted item boundary without publishing a container edit. The boundary update itself owns rendering; structural delegates publish their complete transaction separately.

set : KeyedSeq(value), Key, value -> Try(KeyedSeq(value), Error)

Set is item-local (zero structural visits) but remains journaled so a retained keyed child can receive its replacement value.

move_before : KeyedSeq(value), Key, Placement -> Try(KeyedSeq(value), Error)
apply_raw : KeyedSeq(value), Edit(value) -> Try(KeyedSeq(value), Error)
apply : KeyedSeq(value), Edit(value) -> Try(KeyedSeq(value), Error)
diff : KeyedSeq(value), KeyedSeq(value) -> List(Edit(value)) where [value.is_eq : value, value -> Bool]

Produce an executable semantic journal transforming before into after.

diff_entries : KeyedSeq(value), List({ key : Key, value : value }), List(Edit(value)) -> List(Edit(value)) where [value.is_eq : value, value -> Bool]
debug_valid : KeyedSeq(value) -> Bool

Verify order, reverse indices, values, and ranks for specifications.

Edit : KeyedSeqEdit(value)
Error : [DuplicateKey(Key), MissingAnchor(Key), MissingKey(Key), SlotExhausted]

Style

:= {
    gap : U32 ?? 8,
    padding : U32 ?? 0,
    padding_top : Inset ?? Same,
    padding_right : Inset ?? Same,
    padding_bottom : Inset ?? Same,
    padding_left : Inset ?? Same,
    width : Length ?? Auto,
    height : Length ?? Auto,
    min_width : Length ?? Auto,
    min_height : Length ?? Auto,
    max_width : Length ?? Auto,
    max_height : Length ?? Auto,
    grow : Bool ?? False,
    bg : Color ?? Default,
    hover_bg : Color ?? Default,
    active_bg : Color ?? Default,
    disabled_bg : Color ?? Default,
    disabled_fg : Color ?? Default,
    focus_color : Color ?? Default,
    fg : Color ?? Default,
    border_color : Color ?? Default,
    border_width : U32 ?? 0,
    border_top : Inset ?? Same,
    border_right : Inset ?? Same,
    border_bottom : Inset ?? Same,
    border_left : Inset ?? Same,
    radius : U32 ?? 0,
    font_size : U32 ?? 0,
    font_weight : U32 ?? 0,
    shadow : U32 ?? 0,
    shadow_y : U32 ?? 0,
    shadow_color : Color ?? Default,
    shadow_alpha : U32 ?? 100,
    font_face : FontFace ?? Default,
    text_overflow : TextOverflow ?? Wrap,
    overflow_x : Overflow ?? Visible,
    overflow_y : Overflow ?? Visible,
    align : Align ?? Default,
    justify : Justify ?? Default,
}

Common visual properties. A zero value for font_size or font_weight selects the native default, and a non-zero font_weight is 100 through 900; hover_bg and active_bg apply during pointer interaction. A non-zero shadow is the blur radius of a soft drop shadow, offset down the surface by shadow_y and painted in shadow_color at shadow_alpha percent; shadow: 0 paints none.

inset : U32 -> Inset

Construct a fixed per-side inset.

px : U32 -> Length

Construct a fixed pixel length.

Color

:= [Default, Rgb(U32), Adaptive({ light : U32, dark : U32 })]

A native color, or the control's platform default. A colour is written as a 0xRRGGBB literal. An adaptive colour is a pair the host chooses between by the window's appearance, light or dark, each time it paints, so a change of appearance repaints without rendering the application again.

adaptive : U32, U32 -> Color

A colour for each appearance: light on a light window, dark on a dark one. Both are 0xRRGGBB.

Appearance

:= []

The system's appearance: whether it asks for a light or a dark scheme, and whether it asks for reduced motion. Adaptive colours follow the scheme without any of this; read it when an application decides something by it, such as whether to animate.

current! : () => Settings

The system's appearance now.

next_change! : Settings => Settings

Wait until the system's appearance differs from known and return it. Call from Action.task, with a key so a newer wait supersedes it: cancelling the task interrupts the wait, which then returns known.

prefer! : Preference => {}

Resolve adaptive colours by preference from now on. The window repaints with the scheme it names; the application does not render again. The choice lasts until the next prefer!, not across launches.

Scheme : [Light, Dark]

The colour scheme the system asks for. A system with no preference is Light.

Motion : [Full, Reduced]

Whether the system asks for non-essential motion to be reduced. A system that does not say is Full.

Settings : { scheme : Scheme, motion : Motion }

The system's appearance, as the host last observed it.

Preference : [System, Light, Dark]

Which scheme adaptive colours resolve to: the system's, or one the application chooses over it.

Assets

:= []
beside_executable : Str -> StoreConfig

Root the store at a directory beside the executable. This is the packaged-application choice: the artwork travels with the program, so the store resolves the same way however the program was launched. path is relative to the executable's directory and may not escape it.

working_directory : Str -> StoreConfig

Root the store at a directory relative to the process working directory. This is what running an application from a project checkout wants: the root follows the shell rather than the executable. path is relative to the working directory and may not escape it.

content_directory : StoreConfig

Root the store at the content directory the host provisioned for this application. This is the installed-layout choice, where the artwork lives apart from the program. The application names no path: an asset store is never a way to reach a directory the host did not hand it. Without a provisioned content directory the open reports AccessDenied.

with_manifest : StoreConfig, Manifest -> StoreConfig

Require this store's roc-assets.manifest to match an expectation.

The comparison is against the manifest's own declarations. Nothing walks or hashes the files beneath the root, so opening a store costs the same whether it holds one asset or ten thousand.

stub : Store

The resource-free store value, for pure tests. Reads through it fail.

open! : Access, StoreConfig => Try(Store, AssetErr)

Open the store a config describes, checking its manifest if one was required. Call it from Action.task; it blocks on the disk.

InvalidRoot is a root path this host will not accept -- an absolute path, one holding a NUL, or a relative form that escapes its base. NotFound, NotDirectory, and AccessDenied describe the root itself. ManifestMissing, ManifestUnreadable, and ManifestMalformed describe a required manifest that is absent, unreadable, or not a manifest. AssetSetMismatch, SchemaMismatch, ContentVersionMismatch, and ContentHashMismatch are the four comparisons that can disagree. InvalidExpectation is an expectation this host cannot use, such as a Sha256 string that is not 64 hexadecimal characters.

encode_config : StoreConfig -> { root_kind : U8, root : Str, manifest_required : Bool, asset_set : Str, schema : U32, content_version : U32, content_mode : U8, content_hash : Str }
decode_reason : Dec -> [AccessDenied, AssetSetMismatch, ContentHashMismatch, ContentVersionMismatch, InvalidCapability, InvalidExpectation, InvalidName, InvalidRoot, Io, ManifestMalformed, ManifestMissing, ManifestUnreadable, NotDirectory, NotFound, ResourceLimit, Revoked, SchemaMismatch, Unavailable, Unsupported]

Store

:= AssetStore

An opened asset store: an opaque handle to one directory the host holds open. Every read is made through that handle rather than through the process working directory, which the host never changes.

test_stub : Store

The resource-free store value, for pure tests. It lets an application that keeps a store in its state write that state down in an expect. Reads through it fail; it proves nothing about asset resolution.

read! : Store, Str => Try(List(U8), AssetErr)

Read one asset's bytes, relative to the store's root. Call it from Action.task; it blocks on the disk.

path may name a file in a subdirectory, written with / separators. InvalidName is a path that is absolute, empty, holds a NUL, or contains a . or .. component, and is answered before any file is touched. NotFound is no such file beneath the root, Unsupported is an entry that is a symbolic link or is not a regular file, and ResourceLimit is a file larger than the host reads into one value.

Root : [BesideExecutable(Str), WorkingDirectory(Str), ContentDirectory]

Where a store's root is. The three choices are separate names because moving an executable, changing the working directory, and installing content apart from the program are three different events, and none of them may silently change what another one means.

Content : [AnyContent, Sha256(Str)]

What content a manifest must declare. AnyContent leaves it open, which is what a directory of loose files under development wants. Sha256 carries the 64-character lowercase hexadecimal digest the manifest must declare.

Manifest : { asset_set : Str, schema : U32, content_version : U32, content : Content }

What a required manifest has to say: which asset set it describes, which schema version it was written to, which content version it is, and which content it declares.

ManifestPolicy : [IgnoreManifest, RequireManifest(Manifest)]

Whether opening a store reads the roc-assets.manifest file at its root. IgnoreManifest does not look. RequireManifest fails the open unless the manifest is present and agrees with the expectation, so a half-updated or mismatched asset set is reported at startup instead of surfacing much later as one image that will not draw.

StoreConfig : { root : Root, manifest : ManifestPolicy }

Where a store's root is and whether its manifest is checked. Build one with beside_executable, working_directory, or content_directory, and add an expectation with with_manifest.

Reason : [
    AccessDenied,
    AssetSetMismatch,
    ContentHashMismatch,
    ContentVersionMismatch,
    InvalidCapability,
    InvalidExpectation,
    InvalidName,
    InvalidRoot,
    Io,
    ManifestMalformed,
    ManifestMissing,
    ManifestUnreadable,
    NotDirectory,
    NotFound,
    ResourceLimit,
    Revoked,
    SchemaMismatch,
    Unavailable,
    Unsupported,
]

A stable, portable category for an asset failure.

AssetErr : [OpenStoreErr(Reason), ReadAssetErr(Reason)]

An asset failure. The tag identifies the operation that failed.

Audio

:= []
decode_reason : Dec -> [AccessDenied, DecodeFailed, InvalidCapability, InvalidName, OutputUnavailable, ResourceLimit, Revoked, Unavailable, Unsupported]

Output

:= AudioOutput

The audio output the person granted: an opaque handle to the host's output device. Tracks are loaded through it.

load! : Output, Read, Str => Try(LoadedTrack, AudioErr)

Load one file of a granted directory as a track, by its name in that directory. Call it from Action.task; decoding reads the file.

Track

:= AudioTrack

A loaded track: an opaque handle to decoded audio the host holds.

play! : Track => Try({}, AudioErr)

Start or resume playback.

pause! : Track => Try({}, AudioErr)

Pause playback, keeping the position.

seek! : Track, U64 => Try({}, AudioErr)

Move the position, in milliseconds from the start.

status! : Track => Try(Status, AudioErr)

The track's duration, position and playback state.

stop! : Track => Try({}, AudioErr)

Stop playback and return to the start.

Status : { duration_ms : U64, position_ms : U64, playback : Playback }
Reason : [AccessDenied, DecodeFailed, InvalidCapability, InvalidName, OutputUnavailable, ResourceLimit, Revoked, Unsupported, Unavailable]
AudioErr : [AcquireAudioErr(Reason), LoadAudioErr(Reason), PauseAudioErr(Reason), PlayAudioErr(Reason), SeekAudioErr(Reason), StatusAudioErr(Reason), StopAudioErr(Reason)]

Clipboard

:= []
acquire! : Access => Try(Handle, ClipboardErr)

Acquire the clipboard authority granted by the host.

decode_reason : Dec -> [AccessDenied, ContentTooLarge, InvalidCapability, Revoked, Unavailable]

Handle

:= Clipboard

Opaque authority over the system text clipboard.

read_text! : Handle => Try(Snapshot, ClipboardErr)

Observe the clipboard's current text and its change sequence.

Reason : [AccessDenied, ContentTooLarge, InvalidCapability, Revoked, Unavailable]
ClipboardErr : [AcquireClipboardErr(Reason), ReadClipboardErr(Reason), WriteClipboardErr(Reason)]

Device

:= []

Host-granted HID devices. A grant names one exact device class or virtual device; applications cannot inspect paths or broaden that authority.

acquire! : Access => Try(Grant, DeviceErr)

Acquire only the HID authority configured by the host.

Grant

:= DeviceGrant

Opaque authority over exactly the device the host grant names.

discover! : Grant => Try(List(Info), DeviceErr)

Discover visible devices within this grant. Results are bounded and expose stable USB identity, never operating-system device paths or serial numbers.

connect! : Grant => Try(Connection, DeviceErr)

Connect to exactly the device fixed by the grant.

Connection

:= DeviceConnection

An open connection to one granted device.

transact! : Connection, List(U8) => Try(List(U8), DeviceErr)

Exchange one bounded HID report request and response. The host uses the same operation for physical and deterministic virtual transports.

close! : Connection => Try({}, DeviceErr)

Close a device connection. Closing an already-closed handle is idempotent.

Info : { manufacturer : Str, product : Str, product_id : U16, vendor_id : U16 }
Reason : [AccessDenied, Busy, Closed, Disconnected, InvalidCapability, InvalidRequest, Io, NotFound, Protocol, ResourceLimit, Revoked, Timeout, Unsupported]
DeviceErr : [AcquireDeviceErr(Reason), ConnectDeviceErr(Reason), DiscoverDeviceErr(Reason), TransactDeviceErr(Reason), CloseDeviceErr(Reason)]

Http

:= []
acquire! : Access => Try(Client, HttpErr)

Acquire the network authority explicitly granted by --host-cap-http-origin.

Client

:= HttpClient

Opaque authority to reach exactly the granted origin.

send! : Client, Config, Request => Try(Response, HttpErr)

Send a canonical roc-lang/http request under explicit finite limits.

Reason : [AccessDenied, BodyTooLarge, ConnectFailed, InvalidCapability, InvalidHeader, InvalidRequest, InvalidUrl, RedirectLimit, Revoked, Timeout, UnsupportedScheme]
HttpErr : [AcquireHttpErr(Reason), SendHttpErr(Reason)]

Config

:= {
    timeout_ms : U64 ?? 30_000,
    max_response_bytes : U64 ?? 1024 * 1024,
    max_redirects : U8 ?? 3,
}

The finite limits one exchange runs under. Every field has a default, so a caller states only the limits it actually wants to move.

ImageData

:= []

Bounded metadata and integrity inspection for encoded bytes already obtained through an explicit capability. This module never accepts a path or URL.

decode_reason : Dec -> [Corrupt, InvalidDimensions, ResourceLimit, Unsupported]
Reason : [Corrupt, InvalidDimensions, ResourceLimit, Unsupported]

Process

:= []

Host-granted pseudo-terminal processes. The host grant fixes what starts; applications cannot name or discover executables or profiles.

acquire! : Access => Try(Grant, ProcessErr)

Acquire the process authority explicitly granted with --host-cap-process=local-shell|test-program.

Grant

:= ProcessGrant

Opaque authority to start exactly the granted program.

spawn! : Grant, { columns : U16, rows : U16 } => Try(Pty, ProcessErr)

Start exactly the granted program in a real pseudo-terminal. Rows and columns are bounded to 1..4096.

Pty

:= Pty

One running child attached to a real pseudo-terminal.

read! : Pty, { max_bytes : U32 } => Try(Read, ProcessErr)

Read at most max_bytes bytes (1..65536). Reads block on a task worker, admit one waiter per PTY, and wake as Canceled when the PTY is stopped.

write! : Pty, List(U8) => Try(U32, ProcessErr)

Write one bounded chunk (at most 65536 bytes) to the PTY.

resize! : Pty, { columns : U16, rows : U16 } => Try({}, ProcessErr)

Propagate a bounded terminal size to the child.

cancel! : Pty => Try(Cancel, ProcessErr)

Stop the child and wake an outstanding read. Cancellation is idempotent.

Reason : [AccessDenied, Busy, Exited, InvalidCapability, InvalidSize, Io, ResourceLimit, Revoked, Unsupported]
ProcessErr : [AcquireProcessErr(Reason), CancelProcessErr(Reason), ReadProcessErr(Reason), ResizeProcessErr(Reason), SpawnProcessErr(Reason), WriteProcessErr(Reason)]
Cancel : [AlreadyStopped, Canceled]

Sqlite

:= []
open_read! : Read, Str => Try(Db, SqliteErr)

Open a direct child database in place as a read-only connection. The connection reads the file where it lies, including a write-ahead log a writer is still appending to. The directory authority is consumed normally and may be retained by application state through Roc reference counting.

open_file_read! : Read => Try(Db, SqliteErr)

Open a granted file in place as a read-only connection, exactly as open_read! opens a directory's child. The connection is derived from the file grant, so withdrawing the file withdraws the connection.

decode_value : { ..a, bytes : b, integer : c, kind : Dec, real : d, text : e } -> [Bytes(b), Integer(c), Null, Real(d), String(e)]
decode_reason : { ..a, code : Dec, message : b } -> [AccessDenied(b), Busy(b), Corrupt(b), Interrupted(b), InvalidCapability(b), InvalidName(b), InvalidQuery(b), Io(b), NotDatabase(b), ResourceLimit(b), Revoked(b), Unsupported(b)]
detail : SqliteErr -> Str

Human-readable native detail without discarding the operation tag.

reason_detail : [AccessDenied(a), Busy(a), Corrupt(a), Interrupted(a), InvalidCapability(a), InvalidName(a), InvalidQuery(a), Io(a), NotDatabase(a), ResourceLimit(a), Revoked(a), Unsupported(a)] -> a

Db

:= SqliteRead

An open read-only connection to one database file.

query! : Db, Str => Try(Result, SqliteErr)

Execute one read-only statement and return typed cells. Query text, result dimensions, and aggregate value bytes are bounded by the host; a result longer than the row limit is a ResourceLimit.

query_with! : Db, Str, List(Value) => Try(Result, SqliteErr)

Execute one read-only statement with its ? placeholders bound, in order, to params. Values are bound, never spliced into the text, and the count must match the statement's placeholders.

page! : Db, { sql : Str, params : List(Value), rows : U64 } => Try(Page, SqliteErr)

Execute one read-only statement with bound parameters and return at most rows rows, from 1 to the row limit. more reports whether the result continues past the page; the next page is asked for with a keyset or LIMIT/OFFSET bound as parameters.

watch! : Db => Try(Watch, SqliteErr)

Watch the database this connection reads: its file and its write-ahead log. A committed write by any writer is a Modified change, and a file renamed over the database's name, or the name removed, is Replaced; the connection still reads the file it opened, so a replaced database is read by opening it again. The watch is derived from this connection, so withdrawing the grant the database was opened through ends it.

Reason : [AccessDenied(Str), Busy(Str), Corrupt(Str), Interrupted(Str), InvalidCapability(Str), InvalidName(Str), InvalidQuery(Str), Io(Str), NotDatabase(Str), ResourceLimit(Str), Revoked(Str), Unsupported(Str)]

Portable failure categories with the native SQLite diagnostic retained.

SqliteErr : [OpenDatabaseErr(Reason), QueryDatabaseErr(Reason), WatchDatabaseErr(Reason)]

SystemMonitor

:= []

Host-granted, read-only system observation. No operation exposes host, machine, user, executable path, command line, or environment identity.

acquire! : Access => Try(Sampler, SystemErr)

Acquire the system-observation authority granted by the host.

decode_reason : Dec -> [AccessDenied, Busy, Closed, InvalidCapability, Io, ResourceLimit, Revoked, Unavailable]
decode_snapshot : { ..a, cpu_available : Bool, cpu_tenths : b, disk_available : Bool, disk_read_bytes : c, disk_written_bytes : d, memory_available : Bool, memory_total_bytes : e, memory_used_bytes : f, network_available : Bool, network_received_bytes : g, network_transmitted_bytes : h, processes : i, processes_available : Bool, sequence : j } -> { cpu : [Unavailable([Unsupported]), Value(b)], disk : [Unavailable([Unsupported]), Value({ read_bytes : c, written_bytes : d })], memory : [Unavailable([Unsupported]), Value({ total_bytes : e, used_bytes : f })], network : [Unavailable([Unsupported]), Value({ received_bytes : g, transmitted_bytes : h })], processes : [Unavailable([Unsupported]), Value(i)], sequence : j }

Sampler

:= SystemSampler

Opaque authority to sample this machine's bounded resource counters.

sample! : Sampler => Try(Snapshot, SystemErr)

Refresh and return one bounded snapshot. Call from Action.task.

close! : Sampler => Try({}, SystemErr)

Release the sampler. Repeated close is successful.

Value : [Unavailable(UnavailableReason), Value(a)]
Snapshot : {
    sequence : U64,
    cpu : Value(U16),
    memory : Value({ total_bytes : U64, used_bytes : U64 }),
    disk : Value({ read_bytes : U64, written_bytes : U64 }),
    network : Value({ received_bytes : U64, transmitted_bytes : U64 }),
    processes : Value(List(Process)),
}
Reason : [AccessDenied, Busy, Closed, InvalidCapability, Io, ResourceLimit, Revoked, Unavailable]
SystemErr : [AcquireSystemErr(Reason), CloseSystemErr(Reason), SampleSystemErr(Reason)]

Tcp

:= []
connect! : Access => Try(TcpStream, TcpErr)

Connect to the exact endpoint supplied with --host-cap-tcp.

decode_reason : Dec -> [AccessDenied, Closed, ConnectionFailed, InvalidCapability, InvalidRequest, ResourceLimit, Revoked, Timeout]

TcpStream

:= TcpStream

Opaque authority for one connected, ordered byte stream.

read_up_to! : TcpStream, U64 => Try(List(U8), TcpErr)

Read at most max_bytes; an empty list means orderly end of stream. The requested bound must be from 1 byte through 1 MiB.

write_all! : TcpStream, List(U8) => Try({}, TcpErr)

Write the complete byte list or return an error. One write is bounded to 16 MiB and never reports a partial success.

close! : TcpStream => Try({}, TcpErr)

Shut down the stream. Closing an already closed stream is successful.

Reason : [AccessDenied, Closed, ConnectionFailed, InvalidCapability, InvalidRequest, ResourceLimit, Revoked, Timeout]

A stable, portable category for a stream failure.

TcpErr : [CloseTcpErr(Reason), ConnectTcpErr(Reason), ReadTcpErr(Reason), WriteTcpErr(Reason)]

A stream failure. The tag identifies the operation that failed.

Timer

:= []

Cancellable, pull-based periodic subscriptions.

start! : { interval_ms : U64 } => Try(Handle, TimerErr)

Create a periodic subscription. The interval is 1..60,000 milliseconds. Exactly one next! call may wait at a time, so backpressure is bounded without buffering ticks.

Handle

:= Timer

An opaque, cancellable periodic subscription.

next! : Handle => Tick

Wait for the next tick. Call from Action.task; cancellation wakes the waiting worker and returns Canceled.

cancel! : Handle => CancelResult

Stop this timer. Cancellation is idempotent.

Tick : [Canceled, Fired]

What one wait resolved to.

CancelResult : [AlreadyStopped, Canceled]

What cancelling resolved to.

TimerErr : [InvalidInterval]

A timer failure. Starting is the only operation that can fail.

Event

:= []
Press : {}

A button press. It carries no additional data.

Hover : {}

A pointer entering or exiting an enabled button or a hover region.

Check : { checked : Bool }

A checkbox change containing the newly requested checked state.

Input : { value : Str }

A controlled text edit containing the complete requested value.

Dismiss : {}

A request to dismiss a modal dialog, such as the Escape key.

TextChange : { value : Str }

A committed text edit containing the complete controlled field value.

TextSubmit : { value : Str }

Enter on a single-line text field, carrying its current value.

CanvasPointer : {
    phase : [Begin, Move, End],
    x : I32,
    y : I32,
    target : [None, Some(U64)],
}

A direct-manipulation gesture in canvas coordinates. target is the topmost keyed primitive under the initial press and remains stable for the gesture; an empty point uses None.

CanvasHover : {
    phase : [Move, Leave],
    x : I32,
    y : I32,
    target : [None, Some(U64)],
}

Pointer movement over a canvas with no button pressed, in canvas coordinates. Move carries the topmost keyed shape under the pointer; Leave is delivered once when the pointer leaves the canvas, with the last point it was seen at. A pressed pointer is a CanvasPointer gesture instead, so hovering never interrupts a drag.

CanvasWheel : {
    x : I32,
    y : I32,
    dx : I32,
    dy : I32,
    target : [None, Some(U64)],
}

One wheel or trackpad scroll over a canvas. dx and dy are the scroll distance in logical pixels, positive towards the content's end; a wheel that reports lines is converted at the platform's line height. x, y, and target locate the pointer as for CanvasHover.

CanvasSize : { width : U32, height : U32 }

The size in logical pixels a canvas was laid out at: the surface its primitives are drawn on, inside any border. Delivered once for each size, after a drawn frame gives the canvas one it has not reported.

Key : { keys : Str }

A key chord that matched a shortcut. keys is the chord in the host's canonical spelling, such as ctrl-shift-k: modifiers in a fixed order, then the key, whatever spelling the shortcut was declared with.

VisibleRows : { start : U64, end : U64 }

The rows of a virtual list that intersect its viewport, as the half-open range start up to but not including end. Delivered when that range changes, so an application can page in the data those rows show.

Resize : { size : U32, collapsed : Bool }

A split pane's requested extent: the size in logical pixels of the pane the split sizes, within its minimum and maximum, and whether that pane is collapsed. A collapsed pane keeps size to return to.

Tab : { key : Str }

A tab chosen or closed in a tab strip, named by the key it was given.

Drop : { files : List(FileSelection), refused : List(Refused) }

Files a person dropped on a drop target. files holds each dropped file of a type the target accepts, in the order they were dropped, granted to the application as a read-only file exactly as pick_file! grants a chosen one. refused names every other item dropped, and why it was not granted: a folder or anything else that is not an ordinary file, a file of a type the target does not accept, a file the application may not read, or one that could not be reached.

Refused : { name : Str, reason : [AccessDenied, NotFile, Unavailable, Unsupported] }

One dropped item that was not granted.

TranslateConfig

:= {
    key : Key,
    get : parent -> child,
    set : parent, child -> parent,
    on_delegate : parent -> Action(parent) ?? Action.update,
    memo : [None, Some(child, child -> Bool)] ?? None,
}

Connect a child renderer to parent state and give it a stable lifetime. Start with key, get, and set; add policies only when needed. get reads the child; set replaces it while preserving other parent data. on_delegate receives the proposed parent and defaults to Action.update; returning Action.none() rejects the whole proposal. memo defaults to None. A comparator receives saved and incoming child states: True promises that both the rendered UI and captured handlers remain equivalent. Retaining that comparison snapshot can require cloning during subsequent updates.

TryTranslateConfig

:= {
    key : Key,
    get : parent -> Try(child, [Removed]),
    set : parent, child -> Try(parent, [Removed]),
    on_delegate : parent -> Action(parent) ?? Action.update,
    memo : [None, Some(child, child -> Bool)] ?? None,
}

Connect a removable child by stable identity, not a captured list position. Omit the element when the child is already absent. get and set return Err(Removed) when the projection no longer exists. A rejected setter discards the whole action before delegation or task launch. Preserve unrelated parent data and never recreate a removed child in set. on_delegate and memo follow the same contracts as TranslateConfig.

KeyedColConfig

:= {
    key : Key,
    get : parent -> KeyedSeq(item),
    set : parent, KeyedSeq(item) -> parent,
    on_delegate : parent, Key -> Action(parent) ?? |parent, _key| Action.update(parent),
}

Adapt a persistent keyed sequence into a native column. Every item is a component boundary owned by its complete Key; item actions project by key, so reordering never changes their target and removal cannot recreate one.

VirtualListItem

:= { content : Elem(a), key : U64 }

One stable row in a virtual list. key identifies the row independently of its current index, while content is an ordinary element tree.

CanvasEllipse

:= { key : U64, label : Str, x : I32, y : I32, width : U32, height : U32, fill : Color, stroke : Color ?? Default, stroke_width : U32 ?? 0 }

A retained drawing primitive. Keys must be non-zero and unique within a canvas. Primitives are painted in list order and hit-tested in reverse.

CanvasText

:= { key : U64, label : Str, x : I32, y : I32, width : U32, value : Str, color : Color, size : U32 ?? 12, align : CanvasTextAlign ?? Start }

A single line of text set in the box from x to x + width, with its top at y and a line size * 5 / 4 pixels tall. align places the text within the box; text wider than the box is not clipped. Text is painted but never hit-tested, so a label drawn over a shape leaves the shape as the pointer's target.