Enumerated Types

Enumerated type declarations take the form
def LHS ::= RHS
where LHS is either an atom, the name of the type, or a compound term with distinct type variables as arguments and RHS is an enumeration or a range of integers.

So, for example,

  def man ::= roger | tom | bill | alan | graham | keith |
      sam | fred
  def woman ::= june | mary | rose | penny | sue | helen |
      veronica
  def noun ::= "boy" | "fox" | "girl" | "ball" | "man" |
      "woman" | "lady"
declares man, woman and noun to be the names of types. The right hand sides enumerate the possible values of these types.

It's also possible to have enumerations of numbers as above but also another common enumeration for integers is to use a range as in

  def age ::= 0 .. 110           
  def digit ::= 0 .. 9

In all the above enumerations, all the values are atomic. It it also possible to have compound terms (constructors) in enumerations as in

  def tree(T) ::= empty() | tr(tree(T),T,tree(T))
  def noun_phrase_tree::= np(article,noun_exp_tree)

The first declaration above is a recursive polymorphic type declaration. All the arguments in the constructors on the right hand side must be types (or type variables listed as arguments on the left hand side).