Skip to Content
DocsLanguageType System

Type System

LODE has scalar types (string, bool, int), collections (string[], list<T>, map<string,T>) and named types declared in the schema (record, variant, enum). There are no floats, no implicit coercion and no executable expressions: a LODE value is always plain, finite data.

The four v0.1 types (string, bool, string[], map<string,string>) keep their exact v0.1 meaning, wire encoding and fingerprint.

Type grammar

A field’s type is a type expression:

Type := "string" | "bool" | "int" | "string[]" string set (order-insensitive) | "list<" Type ">" ordered list (order is significant) | "map<string," Type ">" string-keyed map (keys sorted) | Name record, variant or enum from "types" Name := [A-Z][A-Za-z0-9_]*

Every type has exactly one spelling: no whitespace, map keys are always string. map<string,string> is the v0.1 map. Expressions nest freely: list<list<int>>, map<string,list<Rule>>.

Scalars

string

UTF-8 text. Must be well-formed Unicode (no lone surrogates).

Type tag: 0x01

{ "id": 1, "name": "title", "type": "string", "required": true }

bool

A single byte: 0x01 for true, 0x00 for false.

Type tag: 0x02

int v0.2

A signed integer in the range ±(253 − 1). The range is the largest one that is exact in JSON numbers, JavaScript and 64-bit integers, so the same value reads back identically in every language. On the wire an int is 8 bytes, big-endian two’s complement.

An int field may set inclusive bounds:

{ "id": 2, "name": "weightBp", "type": "int", "min": 0, "max": 10000 }

min and max are only allowed on int fields.

Type tag: 0x03

Why no floats? Two producers can print the same float differently (0.1 + 0.2), and fixed-point integers are exact everywhere. Store fractions as scaled integers: basis points (0.85 → 8500), milliseconds, micro-units.

Collections

string[] — string set

An array of strings whose order does not matter. The canonical form and the fingerprint sort it, so ["b","a"] and ["a","b"] are the same value. Duplicates are kept. Use it for keyword sets, tags and capability lists.

Type tag: 0x10

list<T> — ordered list v0.2

An array whose order is part of the value: ["b","a"] and ["a","b"] have different fingerprints. Use it for priority lists, rule tables, pipelines and anything evaluated in sequence. Items cannot be null.

{ "id": 3, "name": "fallbacks", "type": "list<string>" }

Type tag: 0x11

map<string,T> v0.2 for T ≠ string

A string-keyed map. Keys are always sorted in the canonical form and on the wire, so key order never matters. Values cannot be null.

{ "id": 4, "name": "limits", "type": "map<string,int>" }

Type tag: 0x20 for map<string,string>, 0x21 for every other value type.

Named types v0.2

Records, variants and enums are declared in the schema’s types section and referenced by name. See Named Types.

KindJSON valueType tag
recordobject with declared fields0x30
variantobject with exactly one declared field0x30
enumone of the declared strings0x01

Type Tag Registry

TypeTag (hex)Since
string, enums0x01v0.1
bool0x02v0.1
int0x03v0.2
string[]0x10v0.1
list<T>0x11v0.2
map<string,string>0x20v0.1
map<string,T>0x21v0.2
record, variant0x30v0.2

All other tags are reserved.

Type Coercion

LODE performs no implicit type coercion. "5" is not an int, 1 is not a bool. The type checker (check, lodec check) reports every mismatch with its path:

/stages/3/rules/0/emit/weightBp: expected int, got non-integer number 0.95

For v0.1 schemas, compile keeps its v0.1 behaviour: map values are coerced with String().

Required vs Optional

Fields default to required: true if required is omitted. This applies to fields inside records too.

  • Required fields must be present, or check / compile / decode fail
  • Optional fields (required: false) may be absent, undefined or null; all three mean “absent” and produce the same canonical form, bytes and fingerprint
  • Records are closed: a key that is not declared in the type is an error (v0.2 checker)
Last updated on