[m-rev.] for review: constrained polymorphic insts

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Feb 21 18:40:38 AEDT 2002


On 21-Feb-2002, David Overton <dmo at cs.mu.OZ.AU> wrote:
> Index: doc/reference_manual.texi
...
> + at node Constrained polymorphic modes
> + at section Constrained polymorphic modes
> +
> +Mode declarations for predicates and functions may also have inst parameters.
> +However, such parameters must be constrained to be @emph{compatible} with some
> +other inst.
> +The construct @samp{@var{InstParam} =< @var{Inst}},
> +where @var{InstParam} is a variable and @var{Inst} is an inst,
> +states that 
> + at var{InstParam} is constrained to be @emph{compatible} with @var{Inst},
> +that is,
> + at var{InstParam} represents some inst that can be used anywhere where
> + at var{Inst} is required.
> +If an inst parameter occurs more than once in a declaration, it must have the
> +same constraint on each occurrence.

It's not clear from these words what kind of construct InstParam =< Inst is,
or where in the syntax it is allowed to appear.  From the example below,
I can guess that this construct is actually an inst, but this should be
stated explicitly.

> +For example, in the mode declaration
> + at example
> +	:- mode append(in(list_skel(I =< ground)), in(list_skel(I =< ground)),
> +	        out(list_skel(I =< ground))).

Wouldn't it be more consistent to use a syntax similar to the
one that we use for type class constraints, e.g.

	:- mode append(in(list_skel(I)), in(list_skel(I)),
	        out(list_skel(I))) <= I =< ground.

?

Also, is it permitted to constrain one inst parameter as being
compatible with another?

	:- mode foo(in(I =< ground), in(J =< I)).

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list