typexpr:`'`

ident|`(`

typexpr`)`

|typexpr`->`

typexpr|typexpr{`*`

typexpr}+ |typeconstr|typexprtypeconstr|`(`

typexpr{`,`

typexpr}`)`

typeconstr|typexpr`as`

`'`

ident|`<`

[`..`

]`>`

|`<`

method-type{`;`

method-type} [`;`

`..`

]`>`

|`#`

class-path|typexpr`#`

class-path|`(`

typexpr{`,`

typexpr})`#`

class-pathmethod-type:method-name`:`

typexpr

The table below shows the relative precedences and associativity of operators and non-closed type constructions. The constructions with higher precedences come first.

Operator | Associativity |
---|---|

Type constructor application | -- |

* | -- |

-> | right |

as | -- |

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

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.

The type expression `(`

*typexpr* `)`

denotes the same type as
*typexpr*.

The type expression *typexpr*_{1} `->`

*typexpr*_{2} denotes the type of
functions mapping arguments of type *typexpr*_{1} to results of type
*typexpr*_{2}.

The type expression *typexpr*_{1} `*`

...`*`

*typexpr*_{n}
denotes the type of tuples whose elements belong to types *typexpr*_{1},...*typexpr*_{n} respectively.

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 (*typexpr*_{1},...,*typexpr*_{n}) *typeconstr*, where
*typeconstr* is a type constructor with n parameters, denotes the
application of the n-ary type constructor *typeconstr* to the types
*typexpr*_{1} through *typexpr*_{n}.

The type expression *typexpr* `as`

`'`

*ident* denotes the same type as
*typexpr*, and also binds the type variable *ident* to type *typexpr*
both in *typexpr* and in the remaining part of the type.
If the type variable *ident* actually occurs in *typexpr*, a recursive
type is created. Recursive types are only allowed when any recursion
crosses an object type.

An object type
`<`

*method-type* {`;`

*method-type*} `>`

is a record of method types.

The type `<`

*method-type* {`;`

*method-type*} `;`

`..`

`>`

is the
type of an object with methods and their associated types are described by
*method-type*_{1},...,*method-type*_{n}, and possibly some other
methods represented by the ellipsis. This ellipsis actually is
a special kind of type variable, named row variable.

The type `#`

*class-path* is a special kind of abbreviation. This
abbreviation unifies with the type of any object belonging to a subclass
of class *class-path*.
It is handled in a special way as it usually hides a type variable (an
ellipsis, representing the methods that may be added in a subclass).
In particular, it vanishes when the ellipsis gets instantiated.
Each type expression `#`

*class-path* defines a new type variable, so
type `#`

*class-path* `->`

`#`

*class-path* is usually not the same as
type `#`

*class-path* `as`

`'`

*ident* `->`

`'`

*ident*.