Skip to content

Expressions

Every expression is prefix with fixed arity, and there are no parentheses. The parser first collects every signature, constructor and builtin of the file, then parses bodies knowing how many arguments each call takes. Evaluation is strict, arguments left to right.

Form Arity Rule
+ - * / % 2 both i64 or both f64; % is i64 only
== != 2 same primitive type, result bool
< <= > >= 2 both i64 or both f64, result bool
and or 2 bool, short-circuit
not / neg 1 bool / numeric
if c a b 3 c is bool, a and b have the same type
[e1 .. en] n ≥ 1 list T
empty T / none T 1 type empty list T / empty opt T
.f e 1 field of a record
some e 1 opt T
ok e / err e 1 res T E, the other type comes from the expected type (T010 if unknown)
try e 1 unwraps res T E or returns the error early
else e d 2 the value inside opt T or res T E, or the default d
has e / isok e 1 bool
@f 0 a function value, only as an argument to map, filter, fold
if < n 2 n + fib - n 1 fib - n 2

reads as if (n < 2) then n else fib(n - 1) + fib(n - 2): each operator takes exactly as many expressions as its arity.

fn pick o:opt i64 -> i64
ex pick some 5 = 5
ex pick none i64 = 0
else o 0
fn plus r:res i64 str -> res i64 str
ex plus ok 41 = ok 42
ex plus err "x" = err "x"
let n try r
ok + n 1