[mercury-users] Semidet functions

David Glen JEFFERY dgj at cs.mu.OZ.AU
Fri Nov 19 15:27:07 AEDT 1999


On 18-Nov-1999, Ralph Becket <rbeck at microsoft.com> wrote:
> A while back I went through the standard library adding function versions
> of all det predicates with a single output.

Just to throw a spanner into the works, Pete Ross found the following
problem the other day:

:- pred p(pair(int), pair(int)).

p(X, Y) :-
	snd(X) = snd(Y).

This code looks fine at first glance, but because snd is both a predicate and
a function, we get an error along the lines of:

x.m:013: In clause for predicate `x:p/2':
x.m:013:   error: ambiguous overloading causes type ambiguity.
x.m:013:   Possible type assignments include:
x.m:013: V_5 :: (pred int) or int

The compiler doesn't know whether snd(X) is a curried predicate or a value of
type int.

Ulch. A trap for the newcomer!


dgj
-- 
David Jeffery (dgj at cs.mu.oz.au) | If your thesis is utterly vacuous
PhD student,                    | Use first-order predicate calculus.
Dept. of Comp. Sci. & Soft. Eng.|     With sufficient formality
The University of Melbourne     |     The sheerist banality
Australia                       | Will be hailed by the critics: "Miraculous!"
                                |     -- Anon.
--------------------------------------------------------------------------
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