In a programming language like OCaml or Haskell, there are places in the grammar where you need to place a type, and there are other places where you need to place an element of a particular type. For example, when you write
let square : int -> int =
fun x -> x * x
in OCaml, you are asserting two things:
- You are asserting that the code
int -> int describes a type. A theoretician might write this as \mathsf {int}\to \mathsf {int}~\mathit {type}.
- Moreover, you are asserting that the code
fun x -> x * x describes an element of the type described by int -> int. A theoretician might write this as \lambda x\mathpunct {.}x*x:\mathsf {int}\to \mathsf {int}.
The second assertion only makes sense when the first assertion obtains. Indeed, if I had changed int -> int to a bogus piece of code that does not describe a type, then it would not be meaningful to ask whether some other code describes an “element” of this non-type! That’s because only types can have elements.
Per Martin-Löf came up with some terminology that keeps all of this straight. Inspired by him, we define the following: