Type expressions

typexpr:
      ' ident
   |  ( typexpr )
   |  typexpr -> typexpr
   |  typexpr {* typexpr}+
   |  typeconstr
   |  typexpr typeconstr
   |  ( typexpr {, typexpr} ) typeconstr

The table below shows the relative precedences and associativity of operators and non-closed type constructions. The constructions with higher precedences come first.
OperatorAssociativity
Type constructor application--
*--
->right

Type expressions denote types in definitions of data types as well as in type constraints over patterns and expressions.

Type variables

The type expression ' ident stands for the type variable named ident. In data type definitions, type variables are names for the data type parameters. In type constraints, they represent unspecified types that can be instantiated by any type to satisfy the type constraint.

Parenthesized types

The type expression ( typexpr ) denotes the same type as typexpr.

Function types

The type expression typexpr1 -> typexpr2 denotes the type of functions mapping arguments of type typexpr1 to results of type typexpr2.

Tuple types

The type expression typexpr1 *...* typexprn denotes the type of tuples whose elements belong to types typexpr1,...typexprn respectively.

Constructed types

Type constructors with no parameter, as in typeconstr, are type expressions.

The type expression typexpr typeconstr, where typeconstr is a type constructor with one parameter, denotes the application of the unary type constructor typeconstr to the type typexpr.

The type expression (typexpr1,...,typexprn) typeconstr, where typeconstr is a type constructor with n parameters, denotes the application of the n-ary type constructor typeconstr to the types typexpr1 through typexprn.