[mercury-users] boolean expressions from semidet predicates

Mark Brown mark at cs.mu.OZ.AU
Fri May 12 10:58:58 AEST 2006


On 12-May-2006, Nicholas Nethercote <njn at csse.unimelb.edu.au> wrote:
> On Sun, 23 Apr 2006, Mark Brown wrote:
> 
> >>I want to write something like this:
> >>
> >>  require((0 < X) and (X < 10))
> >>
> >>But I can't work out if it's possible to combine semidet operations in 
> >>this
> >>way.  'and' doesn't work, '/\' doesn't work (I'm not even sure what 'and'
> >>and '/\' are, since the reference manual seems to only list the operators
> >>without explaining what they do),
> >
> >It's only concrete syntax.  `X and Y' means the same thing as `and(X, Y)'.
> 
> Which and/2 is this?  The one from bool.m?

It's just a name, like `write_int', `++' or `foo'.  The meaning will of
course depend on the context in which it is used, following the same
overloading resolution rules as any other name.

Incidentally, you can module qualify operators in the following fashion:

	bool.(A and B)

which means the same thing as `bool.and(A, B)'.

> 
> >As for what they "are": `/\' is ISO-Prolog and `and' is an NU-Prolog
> >extension.
> 
> What are their types?

The types, if they even have them, are determined from the context.  But
these names can also be defined as typeclass names or user defined insts,
for example, in which case the concept of type does not apply.  Again,
they are just like any other names -- the fact that these particular names
can be written in infix operator form is only concrete syntax, and is
entirely orthogonal to the type system.

Cheers,
Mark.

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