1Getting Started

2Singleton Types

A singleton type is a type that corresponds to a single value.
The following form defines a new distinct value and simultaneously binds
a variable to that value and a type variable to its singleton type.

(define-constant[const-id:type-id]...+)

The following example defines a new constant nil and defines its
corresponding singleton type Nil:

(define-constant[nil:Nil])

3Variant Types

A variant type or disjoint union type is a type defined as
the union of a fixed set of disjoint subtypes. This is analogous to ML’s datatype
and Haskell’s data. Each variant is either a constant or a structure type.

(define-datatypetype-idvariant-clause...)

(define-datatype(type-idtype-param-id...)variant-clause...)

clause

=

[variant-id#:constantconst-id]

|

[variant-id([field-id:field-type]...)]

The first form defines a monomorphic variant type, and the second form defines a
polymorphic variant type with type variables type-param-id....

The following example defines the type of abstract syntax nodes for an expression grammar
with one constant variant and three structure variants: