Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Product Types

import Lait
#lait

We can put types together to form product types, with syntax S * T, where S and T are types. A value of type S * T is a pair of a value of type S and a value of type T.

We create values of product types using tuples:

#eval (3, "hello") >> (3, "hello")

Given a product type, we can project out the first or second component as follows:

#eval fst (2, 3)>> 2
#eval snd (2, 3) >> 3