## "Fossies" - the Fresh Open Source Software Archive

### Member "gentle-97/html/typedefs.html" (20 Aug 1998, 2477 Bytes) of package /linux/misc/old/gentle-97.tar.gz:

Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links.
You can here alternatively try to

browse the pure source code or just

view or

download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the

**gentle-97.tar.gz** project site itself.

HANDBOOK
/ GENTLE PRIMER
/ Describing Data
/

# Type Definitions

A set of term values is introduced by a type definition.
For example,
the set of terms ` red`, ` yellow`, and ` blue`
can be defined as a type ` Color`
by the type definition
'type' Color
red
yellow
blue

A type definition gives the name of the type
and lists the possible alternatives.
If an alternative is given by a functor with arguments,
then the types
of the arguments are listed.
For example,
a type ` Signal` is defined by

'type' Signal
signal(Color, Color)

A possible value of this type is
` signal(red, yellow)`.
Type definitions may be recursive.
E. g. a type ` ColorList` can be defined by

'type' ColorList
list(Color, ColorList)
nil

Type definitions specify how to construct valid terms of a type:
a value of a type may be obtained by replacing the type names in an
alternative for that type by valid terms of the corresponding types.
For example,
since ` red` is a ` Color` and ` nil` is
a ` ColorList`, one can choose the alternative
` list(Color, ColorList)` and replace ` Color` by ` red`
and ` ColorList` by ` nil` to obtain
` list(red, nil)` as valid term of type ` ColorList`.
Using ` yellow` as ` Color` and the ` ColorList` just constructed,
one can build the more complex term ` list(yellow, list(red, nil))`
of type ` ColorList`.
In a type definition the fields may be given names to document their
meaning, e. g.

list(Head: Color, Tail: ColorList)

The terms considered so far are so-called * ground terms*:
they do not contain variables as placeholders.
A ground term is built from a simple functor without arguments
or by taking already available ground terms and applying a functor to them,
thus yielding a more complex term.