Array format
Every canonical node in the array form, keyword by keyword — the exact JSON that the Structure types serialise to. Field types and shared nodes link back to their definition on the Structure page.
Contents
JSON is the canonical command form every module is stored in — the interchange the other targets render from, not a language you run. These pages describe that form.
- Introduction — what the JSON form is, and how to read the rest of this section.
- Capabilities — which high-level features are possible — deferred to whichever target this JSON renders to.
- Example — a full program using every keyword, in the canonical JSON form.
- Naming considerations — how Program's dotted names are stored, verbatim and un-munged.
- Object format — every node in the self-describing object form, keyword by keyword.
- Array format — every node in the compact tagged-array form, keyword by keyword.
- Project setup — there is no build; how a module file is stored, read and rendered onward.
- Reserved words — why the canonical form has none, and never escapes a name.
Conventions
How each shape maps into array form, node by node:
| Case | Object based | Array based |
|---|---|---|
| A keyword node | an object under its keyword, { "MODULE": { … } } | a tagged array, ["MODULE", …] |
| A union value (one option chosen from several) | a single-key object { "<option>": value } | a two-element array ["<option>", value] |
| An optional value that is absent | the field is null | the position is null |
| An optional value at the end of an array | the key is omitted | the trailing position is dropped entirely |
| A union option carrying no data (e.g. a direction) | the bare option name, "binding" | the bare option name, "binding" |
| An identifier (a declared name) | the bare name string, "Greet" | the bare name string, "Greet" |
ROOT
["ROOT",
[ ["MODULE", "App", [], [], [], [], [], []] ],
[ ["NATIVE", "js", "globalThis.__boot = true;"] ],
[ ["CALL", "App.Main", [], []] ]
]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "ROOT" | Constant tag. |
| 1 · modules | array of MODULE | The top-level modules. |
| 2 · natives | array of NATIVE | Top-level native setup blocks. |
| 3 · run | array of BodyCommand | The run body. |
MODULE
["MODULE", "App", [], [
["TYPE", "Profile", [], [
["FIELD", "name", "Text"]
], [], []]
], [
["FUNCTION", "Greet", [], [
["INPUT", "name", "Text", "forward"]
], [], ["__return", "Text", null], ["implementations", [
["NATIVE", "js", "return 'Hi ' + name;"]
]]]
], [
["LET", "MaxRetries", "Maths.Integer", ["constant", ["literal", ["integer", 3]]]]
], [], []]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "MODULE" | Constant tag. |
| 1 · name | Identifier | The module's name. |
| 2 · modules | array of MODULE | Nested modules. |
| 3 · types | array of TYPE | The module's types. |
| 4 · functions | array of FUNCTION | Derived functions. |
| 5 · constants | array of LET | Module-level constants. |
| 6 · natives | array of FUNCTION | Native functions. |
| 7 · nativeTypes | array of native type | Native type declarations. |
FUNCTION
["FUNCTION", "Welcome", [],
[["INPUT", "profile", "App.Profile", "binding"]],
[["HOLE", "row", "Text", [["INPUT", "line", "Text", "forward"]]]],
["__return", "Text", null],
["body", [
["LET", "label", "Text", ["reference", "profile"]]
]]
]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "FUNCTION" | Constant tag. |
| 1 · name | Identifier | The function's name. |
| 2 · genericTypes | array of Reference | Generic type parameter names. |
| 3 · inputs | array of INPUT | The typed parameters. |
| 4 · holes | array of HOLE | The callback parameters. |
| 5 · return | Return or null | The return, or null. |
| 6 · body | FunctionBody union | ["body", […]] or ["implementations", […]]. |
INPUT
["INPUT", "profile", "App.Profile", "binding"]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "INPUT" | Constant tag. |
| 1 · name | Identifier | The parameter name. |
| 2 · type | Text | The parameter's type. |
| 3 · direction | Direction | Forward, binding or reverse. |
| 4 · optionalDefault | ConstantExpression, trailing | The default; omitted from the end when there is none. |
HOLE
["HOLE", "row", "Text", [
["INPUT", "line", "Text", "forward"]
]]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "HOLE" | Constant tag. |
| 1 · name | Identifier | The hole's name. |
| 2 · type | Text or null | The block's return type, or null. |
| 3 · inputs | array of INPUT | The values passed into the block. |
NATIVE
["NATIVE", "js", "return 'Hi ' + name;"]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "NATIVE" | Constant tag. |
| 1 · platform | Text | The target name. |
| 2 · code | Text | The host source for that target. |
TYPE
["TYPE", "Status", [], [], [
["OPTION", "active", "App.Profile"],
["OPTION", "pending", "Text"]
], []]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "TYPE" | Constant tag. |
| 1 · name | Identifier | The type's name. |
| 2 · genericTypes | array of Reference | Generic type parameter names. |
| 3 · fields | array of FIELD | The record's fields. |
| 4 · options | array of OPTION | The union's options. |
| 5 · natives | array of NATIVE | Per-target native implementations. |
FIELD
["FIELD", "age", "Maths.Integer"]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "FIELD" | Constant tag. |
| 1 · name | Identifier | The field name. |
| 2 · type | Text | The field's type. |
| 3 · optionalDefault | ConstantExpression, trailing | The default; omitted from the end when there is none. |
OPTION
["OPTION", "active", "App.Profile"]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "OPTION" | Constant tag. |
| 1 · name | Identifier | The option name. |
| 2 · type | Text | The option's payload type. |
LET
["LET", "label", "Text",
["call", ["Maths.Integer.ToString", [], [["reference", "count"]]]]
]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "LET" | Constant tag. |
| 1 · name | Identifier | The bound name. |
| 2 · type | Text | The value's type. |
| 3 · value | AssignmentValue union | ["reference", name] or ["call", FunctionCall]. |
STATE
["STATE", "count", "Maths.Integer", ["constant", ["literal", ["integer", 0]]], false]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "STATE" | Constant tag. |
| 1 · name | Identifier | The cell's name. |
| 2 · type | Text | The cell's type. |
| 3 · initial | AssignmentValue or null | The starting value, or null. |
| 4 · lockable | Logic.Maybe | Whether the cell is lockable. |
REVERSE
["REVERSE", "submit", "App.Profile",
[["SET", "saved", "response"]],
[
["LET", "response", "Network.Web.Response",
["call", ["Network.Web.Client.Post", [], [["reference", "profile"]]]]]
]
]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "REVERSE" | Constant tag. |
| 1 · name | Identifier | The reverse's name. |
| 2 · type | Text | The type being written back. |
| 3 · setters | array of SET | The write-backs into outer state. |
| 4 · body | array of BodyCommand | The work done before the write. |
SET
["SET", "saved", "response"]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "SET" | Constant tag. |
| 1 · outerSettable | Text | The outer state cell to write into. |
| 2 · innerValue | Text | The inner value to write. |
WITH
["WITH", "Network.Web.Client", "Network.Web.Mock", [
["LET", "response", "Network.Web.Response",
["call", ["Network.Web.Client.Post", [], [["reference", "profile"]]]]]
]]
| Position | Type | Description |
|---|---|---|
| 0 · tag | "WITH" | Constant tag. |
| 1 · module | Text | The module whose implementation is swapped. |
| 2 · replacement | Text | The module swapped in. |
| 3 · body | array of BodyCommand | The commands the swap applies over. |