19.5 Tuple expression (exp, , exp) and unit expression ()
A tuple expression (exp, , exp) is a syntactic sugar that is equivalent to a record expression with numeric labels {1 = exp, , = exp}. Before it is evaluated, it is translated to its corresponding record expression. In the interactive session of SML#, the type and value of records whose labels are numerals are printed as tuples.
The unit type is the type of empty tuple. Different from the Definition of Standard ML, in SML#, unit and the empty record type {} are distinct; the empty record type has the empty record kind.
The following shows an example of an interactive session using tuples:
# val a = (1, 2);
val a = (1, 2) : int * int
# val b = {1 = 1, 2 = 2};
val b = (1, 2) : int * int
# type foo = {1: int, 2: int}
type foo = int * int
# fun f (x : foo) = (x, x);
# val f = fn : int * int -> (int * int) * (int * int)
val f = fn : int * int -> (int * int) * (int * int)
# f a;
val it = ((1, 2), (1, 2)) : (int * int) * (int * int)
# f b;
val it = ((1, 2), (1, 2)) : (int * int) * (int * int)
# ();
val it = () : unit
# {};
val it = {} : {}