Skip to main content

Type alias

A type alias is an alias to an existing type. This provides for a more concise definition.

For instance, let's assume a function that receives a collection of records as input.

let f(v: collection(record(name: string, age: int))) = ...

If there are multiple functions that receives the same collection type, it would be cumbersome to specify this type over and over again. To avoid this, it's possible to define a type alias, i.e. a new identifier for the type. This can be done as:

let 
my_type = type collection(record(name: string, age: int)),
f(v: my_type) = ...,
g(v: my_type) = ...,
...

Type aliases must be prefixed with the keyword type.

Type aliases can refer to other existing type aliases, e.g.:

let
my_record_type = type record(name: string, age: int),
my_collection_type = type collection(my_record_type),
...