-
-
Notifications
You must be signed in to change notification settings - Fork 3
Data Types
Andrew Johnson edited this page Nov 13, 2024
·
4 revisions
Custom data types are important in LSTS programming.
Records can be declared with typed fields.
type A { a: U64, b: I64 };
Unions can be declared with the bar |
syntax to separate record cases.
type A { a: U64, b: I64 } | B { c: F64 };
Records can be initialized with similar syntax.
let f = A { a: 1, b: -2 };
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;
Destructuring can be fairly intricate.
match f {
A { a: 1, my_b = b } => print(my_b);
_ => print("Unexpected");
};
The LSTS source code and documentation are released under the terms of the attached permissive MIT license. This license is intended only to protect the future development of the project while otherwise allowing people to use the code and IP as they would like. Please, just be nice.