Targets · JSON · Object format

Object format

Every canonical node in the object 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.

Conventions

How each shape maps into object form, node by node:

CaseObject basedArray based
A keyword nodean 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 absentthe field is nullthe position is null
An optional value at the end of an arraythe key is omittedthe 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": {
  "modules": [
    { "MODULE": { "name": "App", "modules": [], "types": [], "functions": [], "constants": [], "natives": [], "nativeTypes": [] } }
  ],
  "natives": [
    { "NATIVE": { "platform": "js", "code": "globalThis.__boot = true;" } }
  ],
  "run": [
    { "CALL": { "functionName": "App.Main", "typeArguments": [], "arguments": [] } }
  ]
} }
ROOT keyword JSON object definition
FieldTypeDescription
modulesarray of MODULEThe top-level modules.
nativesarray of NATIVEPer-target native setup blocks that run as the program starts.
runarray of BodyCommandThe run body: the program's entry point, where a bare CALL may appear.

MODULE

{ "MODULE": {
  "name": "App",
  "modules": [],
  "types": [
    { "TYPE": { "name": "Profile", "genericTypes": [], "fields": [
      { "FIELD": { "name": "name", "type": "Text" } }
    ], "options": [], "natives": [] } }
  ],
  "functions": [
    { "FUNCTION": { "name": "Greet", "genericTypes": [], "inputs": [
      { "INPUT": { "name": "name", "type": "Text", "direction": "forward" } }
    ], "holes": [], "return": { "name": "__return", "type": "Text", "optionalDirection": null },
      "body": { "implementations": [
        { "NATIVE": { "platform": "js", "code": "return 'Hi ' + name;" } }
      ] } } }
  ],
  "constants": [
    { "LET": { "name": "MaxRetries", "type": "Maths.Integer", "value": { "constant": { "literal": { "integer": 3 } } } } }
  ],
  "natives": [],
  "nativeTypes": []
} }
MODULE keyword JSON object definition
FieldTypeDescription
nameIdentifierThe module's name.
modulesarray of MODULENested modules.
typesarray of TYPEThe module's types.
functionsarray of FUNCTIONDerived functions.
constantsarray of LETModule-level constants, each a LET binding a constant expression.
nativesarray of FUNCTIONNative functions (body is implementations).
nativeTypesarray of native typeNative type declarations.

FUNCTION

{ "FUNCTION": {
  "name": "Welcome",
  "genericTypes": [],
  "inputs": [
    { "INPUT": { "name": "profile", "type": "App.Profile", "direction": "binding" } }
  ],
  "holes": [
    { "HOLE": { "name": "row", "type": "Text", "inputs": [
      { "INPUT": { "name": "line", "type": "Text", "direction": "forward" } }
    ] } }
  ],
  "return": { "name": "__return", "type": "Text", "optionalDirection": null },
  "body": { "body": [
    { "LET": { "name": "label", "type": "Text", "value": { "reference": "profile" } } }
  ] }
} }
FUNCTION keyword JSON object definition
FieldTypeDescription
nameIdentifierThe function's name.
genericTypesarray of ReferenceNames of the generic type parameters, if any.
inputsarray of INPUTThe typed parameters.
holesarray of HOLEThe callback parameters the caller fills. Empty for most functions.
returnReturn or nullThe return name and type, or null for no return.
bodyFunctionBody union{ "body": […] } for a derived function, or { "implementations": […] } for a native one.

INPUT

{ "INPUT": { "name": "profile", "type": "App.Profile", "direction": "binding" } }
INPUT keyword JSON object definition
FieldTypeDescription
nameIdentifierThe parameter name.
typeTextThe parameter's type, as a name.
directionDirectionOne of "forward", "binding", "reverse".
defaultConstantExpression, optionalThe default value; the key is absent when there is none.

HOLE

{ "HOLE": { "name": "row", "type": "Text", "inputs": [
  { "INPUT": { "name": "line", "type": "Text", "direction": "forward" } }
] } }
HOLE keyword JSON object definition
FieldTypeDescription
nameIdentifierThe hole's name.
typeText or nullThe block's return type, or null if it returns nothing.
inputsarray of INPUTThe values passed into the block.

NATIVE

{ "NATIVE": { "platform": "js", "code": "return 'Hi ' + name;" } }
NATIVE keyword JSON object definition
FieldTypeDescription
platformTextThe target name: dart, swift, js, nodejs, ts, go, rust, zig, glsl or php.
codeTextThe host source for that target — a function body, or a type alias for a native type.

TYPE

{ "TYPE": {
  "name": "Status",
  "genericTypes": [],
  "fields": [],
  "options": [
    { "OPTION": { "name": "active", "type": "App.Profile" } },
    { "OPTION": { "name": "pending", "type": "Text" } }
  ],
  "natives": []
} }
TYPE keyword JSON object definition
FieldTypeDescription
nameIdentifierThe type's name.
genericTypesarray of ReferenceGeneric type parameter names, if any.
fieldsarray of FIELDThe record's fields; empty for a union or native type.
optionsarray of OPTIONThe union's options; empty for a record or native type.
nativesarray of NATIVEPer-target native implementations; empty for a record or union.

FIELD

{ "FIELD": { "name": "age", "type": "Maths.Integer" } }
FIELD keyword JSON object definition
FieldTypeDescription
nameIdentifierThe field name.
typeTextThe field's type, as a name.
defaultConstantExpression, optionalThe field's default; the key is absent when there is none.

OPTION

{ "OPTION": { "name": "active", "type": "App.Profile" } }
OPTION keyword JSON object definition
FieldTypeDescription
nameIdentifierThe option name; reads back as an Optional of its type.
typeTextThe option's payload type.

LET

{ "LET": {
  "name": "label",
  "type": "Text",
  "value": { "call": {
    "functionName": "Maths.Integer.ToString",
    "typeArguments": [],
    "arguments": [ { "reference": "count" } ]
  } }
} }
LET keyword JSON object definition
FieldTypeDescription
nameIdentifierThe bound name.
typeTextThe value's type.
valueAssignmentValue union{ "reference": name } or { "call": FunctionCall }.

STATE

{ "STATE": { "name": "count", "type": "Maths.Integer", "initial": { "constant": { "literal": { "integer": 0 } } }, "lockable": false } }
STATE keyword JSON object definition
FieldTypeDescription
nameIdentifierThe cell's name.
typeTextThe cell's type.
initialAssignmentValue or nullThe starting value (reference, call or constant), or null for a locked-empty cell.
lockableLogic.Maybetrue for a LOCKED cell, otherwise false.

REVERSE

{ "REVERSE": {
  "name": "submit",
  "type": "App.Profile",
  "body": [
    { "LET": { "name": "response", "type": "Network.Web.Response",
      "value": { "call": {
        "functionName": "Network.Web.Client.Post", "typeArguments": [],
        "arguments": [ { "reference": "profile" } ] } } } }
  ],
  "setters": [
    { "SET": { "outerSettable": "saved", "innerValue": "response" } }
  ]
} }
REVERSE keyword JSON object definition
FieldTypeDescription
nameIdentifierThe reverse's name.
typeTextThe type being written back.
bodyarray of BodyCommandThe work done before the write.
settersarray of SETThe write-backs into outer state.

SET

{ "SET": { "outerSettable": "saved", "innerValue": "response" } }
SET keyword JSON object definition
FieldTypeDescription
outerSettableTextThe outer state cell to write into.
innerValueTextThe name of the inner value to write.

WITH

{ "WITH": {
  "module": "Network.Web.Client",
  "replacement": "Network.Web.Mock",
  "body": [
    { "LET": { "name": "response", "type": "Network.Web.Response",
      "value": { "call": {
        "functionName": "Network.Web.Client.Post", "typeArguments": [],
        "arguments": [ { "reference": "profile" } ] } } } }
  ]
} }
WITH keyword JSON object definition
FieldTypeDescription
moduleTextThe module whose implementation is swapped.
replacementTextThe module swapped in for the block.
bodyarray of BodyCommandThe commands the swap applies over.