for review: document restrictions on equivalence types

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 5 03:15:23 AEDT 1999


Anyone care to review this one?

--------------------

Estimated hours taken: 0.5

Document some previously undocumented restrictions on equivalence types.

doc/reference_manual.texi:
	Explicitly disallow (1) cyclic equivalence types and
	(2) instance declarations containing abstract types
	which are defined as equivalence types. 
	Regarding (1), this was always the intent, but due to
	oversight it was not explicitly stated until now.
	For the rationale for (2), see the recent
	discussion on the mercury-users mailing list.

Index: doc/reference_manual.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.118
diff -u -r1.118 reference_manual.texi
--- reference_manual.texi	1999/01/31 11:51:44	1.118
+++ reference_manual.texi	1999/02/04 16:01:15
@@ -925,7 +925,7 @@
 
 @item
 Equivalence types: these are type abbreviations.
-They are defined using `==' as follows.
+They are defined using @samp{==} as follows.
 They may be polymorphic.
 
 @example
@@ -936,6 +936,10 @@
 
 Like discriminated union type definitions,
 equivalence type definitions must be transparent.
+Unlike discriminated union type definitions,
+equivalence type definitions must not be cyclic;
+that is, the type on the left hand side of the @samp{==}
+must not occur on the right hand side of the @samp{==}.
 
 Mercury treats an equivalence type
 as an abbreviation for the type on the right hand side of the definition;
@@ -2853,8 +2857,10 @@
 An @samp{instance} declaration gives a type for each parameter of the
 typeclass.  Each of these types must be either a type with no arguments, or 
 a polymorphic type whose arguments are all distinct type variables.  e.g. 
- at code{int}, @code{list(T)} and @code{map(K,V)} are allowed but
- at code{T}, @code{list(int)} and @code{map(T,T)} are not.
+ at code{int}, @code{list(T)} and @code{bintree(K,V)} are allowed but
+ at code{T}, @code{list(int)} and @code{bintree(T,T)} are not.
+The types in an instance declaration must not be abstract types which
+are elsewhere defined as equivalence types.
 A program may not contain more than one @code{instance} declaration for a
 particular type (or set of types, in the case of a multi-parameter
 typeclass).  These restrictions ensure that there are no overlapping instance

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh>  |   but source code lives forever"
PGP: finger fjh at 128.250.37.3        |     -- leaked Microsoft memo.



More information about the developers mailing list