Definition - “for all”

A dependent function type is the type of functions whose result type depends on the input value. Given a type and a type family we construct a type of dependent functions:

A term of this type is a function , given its input , returns a term of Formally, if , then for any we will have

Type family and dependent function type

Link to original

Example 1

Suppose we have type and type family defined by and a function will returns a when given and a when given .

Example: fmax

we can define a dependent function that gives the “largest” element of the resulting type. We can let . Note that (see Definition of Fin(n))

Polymorphic

we can also use types as parameters, such constructed dependent functions are polymorphic over a give universe.

Example: id

Let is now a function that accept a type as input and return type as output.

we generally call as using -calculus which gives