Type System

AodhML uses a static, nominative type system with type inference. Types are checked at compile time, eliminating an entire class of runtime errors.

Type Categories

Scalar Types

TypeSizeRange
i88 bits-128 to 127
i1616 bits-32,768 to 32,767
i3232 bits-2^31 to 2^31-1
i6464 bits-2^63 to 2^63-1
u88 bits0 to 255
u1616 bits0 to 65,535
u3232 bits0 to 2^32-1
u6464 bits0 to 2^64-1
f3232 bitsIEEE 754 single
f6464 bitsIEEE 754 double
bool1 bittrue, false

Compound Types

// Array — homogeneous, fixed-size at creation
let arr: [i32] = [1, 2, 3]

// Tuple — heterogeneous, fixed-size
let pair: (i32, String) = (42, "answer")

// Struct — named fields
type Point = struct { x: f64, y: f64 }

// Enum — tagged union
type Result<T, E> = enum {
    Ok(T),
    Err(E),
}

Generic Types

// Generic struct
type Box<T> = struct {
    value: T,
}

// Generic function
fn identity<T>(x: T) -> T {
    return x
}

// Trait bounds
fn max<T: Comparable>(a: T, b: T) -> T {
    if a > b { return a } else { return b }
}

AI-Native Types

TypeDescriptionStatus
Tensor<T>N-dimensional arrayPartial
Dataset<X, Y>Training data containerPlanned
ModelNeural network model traitPlanned
DeviceExecution device (CPU/GPU)Planned
ParameterTrainable parameterPlanned

Type Inference

The compiler infers types from context:

let x = 42              // i32 (default integer)
let y = 3.14            // f64 (default float)
let z = [1, 2, 3]       // [i32]
let w = true            // bool

// Explicit when ambiguous
let a: u64 = 42
let b: f32 = 3.14