[m-dev.] polymorphic modes

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Feb 9 19:48:01 AEDT 2000


On 09-Feb-2000, David Overton <dmo at ender.cs.mu.oz.au> wrote:
> Several weeks ago on the mercury_users list there was a discussion
> about adding polymorphic modes where the inst parameters were
> constrained to being ground(shared).
> 
> I proposed a syntax something like
> 
> 	:- mode p(in(I), out(I)) <= ground(I).
> 
> to describe these constrained polymorphic modes.

How about

	:- mode p(in(I), out(I)) <= I is ground.

?

The point of this is that in future we might want
to generalize this to allow insts other than `ground'
on the RHS of the `is'.  For example, it might make
sense to allow `constrained' (a.k.a. `any' or `old'
in HAL terminology) there, and perhaps even more
complicated insts such as `list_skel(any)'.


One problem that people writing code using this extension
will run into is that the standard library does not use
polymorphic modes.  So for code that uses the standard
library, it will typically not be OK to give the code a
polymorphic mode declaration.

One solution would be to change all the appropriate mode
declarations in the standard library to be polymorphic. 
Another solution would be to propagate polymorphism in
the types into the modes, as alluded to in my proposal
for subtypes.  But that would require adding type class
constraints in various places, which would break backwards
compatibility.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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