[m-dev.] diff: improve "Types" chapter of reference manual
Simon Taylor
stayl at cs.mu.OZ.AU
Fri Jan 7 14:02:04 AEDT 2000
Estimated hours taken: 0.25
doc/reference_manual.texi:
Improve the structure of the "Types" chapter by
adding menus and sectioning commands.
Index: reference_manual.texi
===================================================================
RCS file: /home/staff/zs/imp/mercury/doc/reference_manual.texi,v
retrieving revision 1.163
diff -u -u -r1.163 reference_manual.texi
--- reference_manual.texi 2000/01/07 02:39:22 1.163
+++ reference_manual.texi 2000/01/07 02:54:24
@@ -915,6 +915,15 @@
type classes (@pxref{Type classes}), and existentially quantified types
(@pxref{Existential types}).
+ at menu
+* Builtin types::
+* User-defined types::
+* Predicate and function types::
+ at end menu
+
+ at node Builtin types
+ at section Builtin types
+
Certain special types are builtin, or are defined in the Mercury library:
@table @asis
@@ -945,13 +954,22 @@
@end table
+ at node User-defined types
+ at section User-defined types
+
New types can be introduced with @samp{:- type} declarations.
There are several categories of derived types:
+
+ at menu
+* Discriminated unions::
+* Equivalence types::
+* Abstract types::
+ at end menu
- at itemize @bullet
- at item
-Discriminated unions: these encompass both enumeration and
-record types in other languages.
+ at node Discriminated unions
+ at subsection Discriminated unions
+
+These encompass both enumeration and record types in other languages.
A derived type is defined using @samp{:- type @var{type} ---> @var{body}}.
(Note there are @emph{three} dashes in that arrow.
It should not be confused with the two-dash arrow used for DCGs
@@ -1033,8 +1051,22 @@
Having two different definitions of a type with the same name and arity in
the same module is an error.
- at item
-Equivalence types: these are type abbreviations.
+Constructors may be overloaded among different types:
+there may be any number of constructors with a given name and arity,
+so long as they all have different types.
+However, there must not be more than one constructor
+with the same name, arity, and result type in the same module.
+(There is no particularly good reason for this restriction;
+in the future we may allow several such functors
+as long as they have different argument types.)
+Note that excessive overloading of constructors can slow down type checking
+and can make the program confusing for human readers,
+so overloading should not be over-used.
+
+ at node Equivalence types
+ at subsection Equivalence types
+
+These are type abbreviations.
They are defined using @samp{==} as follows.
They may be polymorphic.
@@ -1056,8 +1088,10 @@
the two are equivalent in all respects
in scopes where the equivalence type is visible.
- at item
-Abstract types: these are types whose implementation is hidden.
+ at node Abstract types
+ at subsection Abstract types
+
+These are types whose implementation is hidden.
The type declarations
@example
@@ -1075,20 +1109,9 @@
named in the interface section of the module.
Abstract types may be defined as either discriminated union types
or as equivalence types.
-
- at end itemize
-Constructors may be overloaded among different types:
-there may be any number of constructors with a given name and arity,
-so long as they all have different types.
-However, there must not be more than one constructor
-with the same name, arity, and result type in the same module.
-(There is no particularly good reason for this restriction;
-in the future we may allow several such functors
-as long as they have different argument types.)
-Note that excessive overloading of constructors can slow down type checking
-and can make the program confusing for human readers,
-so overloading should not be over-used.
+ at node Predicate and function types
+ at section Predicate and function types
The argument types of each predicate
must be explicitly declared with a @samp{:- pred} declaration.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list