[mercury-users] Syntactic sugar for higher order types and modes

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Jul 23 08:52:22 AEST 2000

On 22-Jul-2000, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> On 21-Jul-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > 	- I guess we could also use infix `:' in `mode' declarations...
> > 
> > 		:- inst bar_mode1 == (pred(in, out) is det).
> > 		:- inst bar_mode2 == (pred(out, in) is nondet).
> > 		:- inst baz_mode == (func(in) = out is det).
> Bzzt.  :- inst uses `=' not `==' (but see below for a more sane syntax).

Although only the "=" syntax is documented in the language reference
manual, the compiler actually accepts either.

> Defining a mode should be done using  ==
> 	:- mode foo == inst1 -> inst2.

Actually the compiler allows mode declarations with `==',
just like it does for inst declarations.  But unfortunately
declarations like the one above don't work, because `==' and `->' have
the wrong relative precedence.  That parses as

 	:- mode ((foo == inst1) -> inst2).

So currently to use `==' you need to write it as

	:- mode foo == (inst1 -> inst2).

This precedence issue was the main reason why we chose to document
`::' rather than `==' as the syntax for mode definitions.

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        |     -- the last words of T. S. Garp.
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe

More information about the users mailing list