Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Program Style

Canonical formatting

Adam ships its own formatter (adam fmt, backed by format_sheet) with one canonical layout: 4-space indentation, opening braces on the same line as the keyword that introduces them, and no space before a declaration’s closing ;. Given input that doesn’t already follow this layout, formatting normalizes it:

sheet s {
    cell x: i32 = 1;
    cell y: i32 = 2;
}

A formatter run is expected to be idempotent (formatting already-canonical source reproduces it unchanged) and preserves every comment, doc comment, and blank line exactly where it appeared, including a file-header comment before sheet itself and a trailing comment before a block’s own closing }. adam-lsp’s textDocument/formatting handler refuses to format a sheet with any recorded syntax error rather than guess at intent: format_sheet’s own precondition is that sheet.errors is empty.

A conditional branch’s trailing , (the grammar allows one after each branch’s closing }) is always omitted by the formatter, even though the parser still accepts it on input, so canonical Adam source never has one.