Language Guide

Syntax, types, semantics, the effect system, specs, and builtins — a complete reference.

Values & Types

Simple types: i64, f64, bool, str. Integer literals support decimal, hex (0x), binary (0b), and octal (0o). Type inference works from literals. [T] is sugar for Vec<T>.

Functions

Functions are defined with fn. Parameters are name: type pairs. The return type follows ->. Every program must define main. Functions can be forward-declared by omitting the body.

Control Flow

if/else, while, and for-in ranges. Semicolons are optional. Early return is the usual error path.

Structs, Impl, Generics & Traits

Structs are composite types with C-compatible layout. impl attaches methods. 0.9 adds generic functions and structs (monomorphization) and traits/impl.

Enums & Pattern Matching

Enums are tagged unions. match is exhaustive — the compiler checks every case. _ is the wildcard.

Specs — Write What, Then How

spec declares WHAT a function should do. The implementation follows. --verify proves or refutes requires/ensures statically on the stated fragment — with counterexamples, or an honest UNKNOWN.

Effects — Side Effects in the Type

Effects are type dimensions. Unhandled effects are compile-time errors. 0.9 adds effect payloads (!E(T), raise/catch) and !Overflow as a type-level effect: omit it and you claim arithmetic safety.

Concurrency — go/join with !Par

go spawns an OS thread; join waits for the result. !Par marks parallel execution. No hidden thread pools. --verify reasons about fork–join and handle protocols.