AXIOM Axiom Documentation
UABLACKGRAYWHITE
Axiom · dark

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

Contextual enum resolutionAxiom
1color:2    | red3    | green4    | blue5END color67paint(color c):8    if c == red:9        RETURN
1

Starts a named ADT.

2

A variant without payload.

5

Closes the type.

7

The parameter establishes expected type.

8

So red resolves to color.red.

Result without exceptions

Error as dataAxiom
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)
1

The signature says success or typed error.

2

Target-surface ? propagates an error variant; it does not throw.

3

Parsing may also fail.

4

The success variant is inferred from the expected return type.

Pattern matching

Exhaustive matchAxiom
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"
2

The scrutinee type gives context to all variants.

3

Extract the success payload.

5

Match a specific nested error.

7

Handle the remaining I/O errors; exhaustiveness is checked.

Generic types

Generic declarationAxiom
1-- T2pair:3    T first4    T second5END pair
1

Declares a type parameter for the next declaration.

2

A normal structural type.

3

A T-valued field.

5

Closes the type.