Definition

In Type Theory, a type constructor is an operation that builds new types from existing types. Type constructors take one or more types as parameters and produce a new type.

A type constructor can be viewed as a function at the type level: it maps types to types rather than values to values.

Examples

Nullary Type Constructors

Type constructors with no parameters are simply base types:

  • : Natural numbers
  • : Boolean values

Unary Type Constructors

Type constructors taking one type parameter:

  • : Lists of elements of type
  • : Optional values of type
  • : Trees with nodes labeled by

Binary Type Constructors

Type constructors taking two type parameters:

Higher-Order Type Constructors

Type constructors can themselves take type constructors as arguments. For example, a functor or monad is a higher-order type constructor.

Dependent Type Constructors

In dependently typed language, type constructors can depend on values, not just types:

  • : Vectors of type with length
  • : Dependent Pair where is a type family indexed by
  • : Dependent Function Type where the codomain depends on the input