A Unison term declaration (or "term binding") consists of an optional type signature, and a term definition. For example:
timesTwo : Nat -> Nat
timesTwo x = x * 2
The first line in the above is a type signature. The type signature timesTwo : Nat -> Nat
declares that the term named timesTwo
is a function accepting an argument of type Nat
and computes a value of type Nat
. The type Nat
is the type of 64-bit natural numbers starting from zero. See Unison types for details.
The second line is the term definition. The =
sign splits the definition into a left-hand side, which is the term being defined, and the right-hand side, which is the definition of the term.
The general form of a term binding is:
name : Type
name p_1 p_2 … p_n = expression