Function application

A function applicationf a1 a2 anapplies the functionfto the argumentsa1throughan.

The above syntax is valid wherefis aregular identifier.If the function name is an operator such as*,then the syntax for application is infix :a1 * a2.Any operator can be used in prefix position by surrounding it in parentheses:(*) a1 a2.

All Unison functions are ofarity1. That is, they take exactly one argument. An n-ary function is modeled either as a unary function that returns a further function (a partially applied function) which accepts the rest of the arguments, or as a unary function that accepts a tuple.

Function application associates to the left, so the expressionf a bis the same as(f a) b.Iffhas typeT1 -> T2 -> Tnthenf ais well typed only ifahas typeT1.The type off ais thenT2 -> Tn.The type constructor of function types,->,associates to the right. SoT1 -> T2 -> Tnparenthesizes asT1 -> (T2 -> TN).

The evaluation semantics of function application is applicative orderCall-by-Value.In the expressionf x y,xandyare fully evaluated in left-to-right order, thenfis fully evaluated, thenxandyare substituted into the body off,and lastly the body is evaluated.

An exception to the evaluation semantics isBoolean expressions,which have non-strict semantics.

Unison supportsproper tail callsso function calls in tail position do not grow the call stack.