Types and algebraic data types
Enums and payload-carrying variants use one sum-type model, without nullable magic.
Axiom keeps nominal type identity while allowing short variant names when the expected type is unambiguous.
An enum is a payload-free sum type
1color:2 | red3 | green4 | blue5END color67paint(color c):8 if c == red:9 RETURNStarts a named ADT.
A variant without payload.
Closes the type.
The parameter establishes expected type.
So red resolves to color.red.
Result without exceptions
1load_port(text path) -> result<u16, io_error>:2 const text raw = fs.read_text(path)?3 const u16 port = text.parse_u16(raw)?4 RETURN ok(port)The signature says success or typed error.
Target-surface ? propagates an error variant; it does not throw.
Parsing may also fail.
The success variant is inferred from the expected return type.
Pattern matching
1describe(result<u16, io_error> value) -> text:2 match value:3 ok(port):4 RETURN text.format("port={}", port)5 error(permission_denied):6 RETURN "permission denied"7 error(_):8 RETURN "I/O error"The scrutinee type gives context to all variants.
Extract the success payload.
Match a specific nested error.
Handle the remaining I/O errors; exhaustiveness is checked.
Generic types
1-- T2pair:3 T first4 T second5END pairDeclares a type parameter for the next declaration.
A normal structural type.
A T-valued field.
Closes the type.