Skip to content

Data Types

Andrew Johnson edited this page Nov 13, 2024 · 13 revisions

Custom data types are important in LSTS programming.

Records

Records can be declared with typed fields.

type A { a: U64, b: I64 };

Tagged Unions

Unions can be declared with the bar | syntax to separate record cases.

type A { a: U64, b: I64 } | B { c: F64 };

Initialize a Record

Records can be initialized with similar syntax.

let f = A { a: 1, b: -2 };

Destructuring a Record

Records can be destructured on the left-hand-side of an expression to match its shape or bind its fields.

let A { my_a = a } = f;
Clone this wiki locally