A type of n-tuples is a collection of sequences of length n.
- An example of a type of 2-tuples is the type of ordered pairs of integers Int×Int populated e.g. by (1,1).
- An example of a type of 3-tuples is the type of ordered triples of integers, for instance:
- Int×Int×Int populated e.g. by (1,2,3), or
- Int×String×Int populated e.g. by (1,“two”,3).
- An n-tuple type can be viewed as a type of lists of length n. Though every individual list is a tuple, a list type is not a tuple type because a list type can have elements of different lengths.
- You can have 1-tuple types, or even the 0-tuple typed which is populated by () the empty tuple!
- Generally, if I say “tuple” without specifying n then I mean a 2-tuple: an ordered pair. See also the Wikipedia article.
- You may wonder what use a 1-tuple type is—why not just use the underlying type instead of the same type in a wrapping of a useless bracket? Well, you could, but consider this: the type char might be viewed as a 1-tuple of byte, in the sense that “a” is actually an element of [0..255] in a wrapper saying “I am ASCII”. Such type-wrappers are a sign of a high-level language, which SML certainly is. More on this later, perhaps.