Expressions
x
: variables100
: numbers#t|#f
: the true and false literals(\|λ)x: t. e
: a lambda expression with x
bound to type t
let x: t = e1 in e2
: binds x
to e1
and then evaluates e2
f a
: application to a lambdaif e1 then e2 else e3
: an if-then-else expressionref e
: boxes e
and returns a reference to it!r
: unboxes the value at reference r
r := e
: places the value of e
in the reference r
All type annotations of form : t
are optional. If not specified, the
type defaults to the unknown type ?
. There is also the special type marker
_
, which instructs the compiler to infer a principal type.
Types
?
: the unknown type, admitting any value_
: mark type to be inferrednat
: the type of natural numbersbool
: the type of booleanst1 -> t2
: function typeref t
: a reference typeBuiltin Functions
succ: nat -> nat
succ n
is n + 1
pred: nat -> nat
pred n
is n - 1
add: nat -> nat -> nat
add m n
is m + n
mult: nat -> nat -> nat
mult m n
is m * n
eqn: nat -> nat -> bool
eqn m n
is m == n
eqb: bool -> bool -> bool
eqb b c
is b == c