Skip to content

Empty types (also called Placeholder types)

An empty type has no values belonging to it (apart from the undefined value, undef, which is a member of every type). Empty types are declared as follows:

    widget :: type

this declares widget to be a type but gives it no values.

Empty types can be used during program development as placeholders for types whose representation is not yet decided. For example given the above declaration we can give type specifications involving widget, e.g.

    foo :: num->widget->widget
    gronk :: [widget]->widget

and write code using foo' andgronk` which can be checked for type correctness. At a later stage the specification of widget as an empty type can be replaced by a non-empty type definition using ==, ::=, or abstype, allowing foo, gronk, to be defined.

Typenames declared as empty can have any arity, eg

    table * ** :: type

This creates a family of empty types, such as table num bool and so on. They are all devoid of values (apart from undef). The general form of this kind of specification is

    tform-list :: type

where tform consists of a typename followed by zero or more generic type variables (and it is permitted to declare several such types simultaneously, separated by commas, whence tform-list).

An empty type may be considered equivalent to an algebraic type with no constructors.