Documentation

ARIA-IR Language Reference

v0.1.0

Module Declaration

Every ARIA-IR program is a module. The module is the top-level container for functions and exports.

(module "name"
  (func ...)
  (export ...))

Functions

Functions are declared with func. Parameters, return types, effects, and intent are all declared explicitly.

(func $name
  (param $x i32)
  (param $y i32)
  (result i32)
  (effects pure)
  (intent "Add two integers")
  (return (add.i32 $x $y)))
$name Mutable binding / function name. Prefixed with $.
%name Immutable binding (SSA). Prefixed with %. Cannot be reassigned.

Type System

ARIA-IR uses explicit, type-suffixed operations. There is no implicit coercion.

i32
i64
f32
f64
bool
str
void

Operations carry their type: add.i32, mul.f64, lt.i32, concat.str.

Effect System

Every function declares its effects. The type checker verifies these declarations at compile time.

pure No side effects. Can be memoized, reordered, or eliminated.
mem Memory effects. Reads or writes mutable state.
io I/O effects. Interacts with the outside world (print, file, network).
div Divergence. May not terminate (loops, recursion).

Intent Annotations

The intent node carries the AI's stated purpose for a function. It is preserved through compilation and available for verification in Layer 4.

(intent "Compute the nth Fibonacci number using recursion")

Intent annotations are not comments. They are first-class nodes in the AST. They travel with the code through the pipeline.

Control Flow

Conditionals

(if (lt.i32 $x 10)
  (then (return $x))
  (else (return (sub.i32 $x 1))))

Loops

(loop $label
  (if (ge.i32 $i $n)
    (then (br $label))
    (else
      ;; loop body
      (set $i (add.i32 $i 1)))))

br breaks out of the named loop.

Bindings

;; Immutable (SSA)
(let %result i32 (add.i32 $x $y))

;; Mutable local
(local mut $counter i32 0)
(set $counter (add.i32 $counter 1))

Exports

Functions must be explicitly exported to be visible outside the module. The $main export is the entry point.

(export $main)
(export $fibonacci)

Example Programs

The examples/ directory contains complete programs:

fibonacci.aria Recursive and iterative Fibonacci. Demonstrates recursion, loops, intent.
bubble_sort.aria Array sorting. Demonstrates mutable state, nested loops, memory effects.
math_demo.aria Arithmetic operations. Demonstrates type-suffixed ops, pure functions.