[m-dev.] polymorphic modes

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Feb 19 22:21:36 AEDT 2000


On 10-Feb-2000, David Overton <dmo at hydra.cs.mu.oz.au> wrote:
> On Wed, 09 Feb, 2000 at 07:48:01PM EST, Fergus Henderson wrote:
> > 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.
> > 
> > ?
> 
> Ok, but the main thing I'm worried about, as far as the syntax is
> concerned, is how this interacts with typeclass constraints and
> determinism declarations which may both appear at the same point as
> these inst constraints.  One of these already uses `<=' and the other
> already uses `is'.

Hmm, good point.

> How do these look:
> 
> :- mode p(in(I), out(I)) <= (I is ground) is det.
> 
> :- pred p(T::in(I), T::out(I)) <= (fooable(T), I is ground) is det.
> 
> ?

Well, the use of `<=' for both type class constraints on types
and groundness constraints on insts looks fine, at least to my eyes,
so long as you have the rule that each variable in a combined pred-mode
declaration can either be a type variable or an inst variable but not both.
But the `... (I is ground) is det' is not so nice.

How about using `(I::ground)'?

:- pred p(T, T) <= fooable(T).
:- mode p(in(I), out(I)) <= (I is ground) is det.

:- func f(T, int) = T <= fooable(T).
:- mode f(in(I), in) = out(I) <= (I :: ground) is det.

:- pred p(T::in(I), T::out(I)) <= (fooable(T), (I::ground)) is det.

:- pred f(T::in(I), int::in) = (T::out(I)) <= (fooable(T), (I::ground)) is det.

Or alternatively, perhaps `I >= ground'?

-- 
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