Expressions

value-identifier
the value bound to the identifier.

data-constant-identifier
a data constant.

data-constructor-identifier
a data constructor.

numeric-literal
1, 2, ... are abbreviations for succ(0), succ(succ(0)) etc.

' c'
character constant.

" string"
abbreviation for a list of characters.

[ expression_ 1, ..., expression_ n]
equivalent to ` expression_ 1 :: ... :: expression_ n :: nil'.

[]
equivalent to `nil'.

expression_ 1, expression_ 2
a pair formed from the values of expression_ 1 and expression_ 2.

( expression)
same as expression.

expression_ 1 expression_ 2
the result of applying the function or constructor value of expression_ 1 to the value of expression_ 2.

lambda pattern_ 1 => expression_ 1 | ... | pattern_ k => expression_ k
an anonymous function. See Semantics of pattern matching.

if expression_ 1 then expression_ 2 else expression_ 3
a conditional expression, equal to expression_ 2 if expression_ 1 is true, or expression_ 3 if it is false.

let pattern == expression_ 1 in expression_ 2
the same as expression_ 2, with the variables in expression_ 2 replaced by the values assigned to them in matching pattern to expression_ 1. It is equivalent to
(lambda
pattern
=>
expression
_
2
)
expression
_
1

letrec pattern == expression_ 1 in expression_ 2
like let, except that pattern must be irrefutable, and its variables may also appear in expression_ 1. It is a more efficient version of
(lambda
pattern
=>
expression
_
2
)(fix(lambda
pattern
=>
expression
_
1
))
for a function fix defined as
      dec fix: (alpha -> alpha) -> alpha;
      --- fix f <= f(fix f);

expression_ 1 where pattern == expression_ 2
same as `let pattern == expression_ 2 in expression_ 1'.

expression_ 1 whererec pattern == expression_ 2
same as `letrec pattern == expression_ 2 in expression_ 1'.

Ambiguities in patterns and expressions are resolved by the following binding precedences, from weakest to strongest:

For any infix operators @ and expression e, the following abbreviations, called operator sections, are permitted:
( e @)
is short for lambda x => e @ x.

( @ e)
is short for lambda x => x @ e.



Ross Paterson <ross@soi.city.ac.uk>