Tuples

Learn about the tuple type.

We'll cover the following

So far, we have only dealt with functions that take exactly one argument and yield exactly one result. This may seem limiting, but in some sense, that’s all there is to Haskell functions. They have one argument type and one result type. But these types do not have to be the primitive types that we have learned about so far. We will look at tuples as an example of more complex types built from simpler types.

Tuple types

A tuple is a finite, ordered sequence of values. For example, (5, True) is a tuple containing the integer 5 and the boolean True. It has the tuple type (Int, Bool), representing values that contain first an Int value and second a Bool value.

Tuples do not need to be pairs, there are also triples, 4-tuples and so on. Here are some examples of tuple types and values:

Get hands-on with 1200+ tech skills courses.