Represents a type declaration in a Whiley source file, which has the form:
"type" Identifier "is" TypePattern ["where" Expression]
Here, the type pattern specifies a type which may additionally be adorned with variable names. The "where" clause is optional and is often referred to as the type's "constraint". Variables defined within the type pattern may be used within this constraint expressions. A simple example to illustrate is:
type nat is (int x) where x >= 0
Here, we are defining a
constrained type called
nat
which represents the set of natural numbers (i.e the non-negative integers). Type declarations may also have modifiers, such as
public
and
private
.
@author David J. Pearce