[mercury-users] Beginner question about pairs

Dave Slutzkin dave_slutzkin at yahoo.com
Sun Jun 17 21:58:40 AEST 2001


G'day.

I've just started learning Mercury, after having some
reasonable familiarity with Prolog.  (This seems to do
more harm than good...)

In the following code:

% added for explicit typing in check_place
:- pred cptemp(int,int,int,int).
cptemp(_,_,_,_).

:- pred
check_place(pair(int,int),list(pair(int,int))).
:- mode check_place(in,in) is det.
check_place(_,[]).
% line 69 follows...
check_place(X-Y,[(OldX-OldY)|Rest]) :-
	cptemp(X,Y,OldX,OldY) ,
	(if (Y=OldY) then fail else true) ,
	(if abs(minus(OldX,X))=abs(minus(OldY,Y)) then fail
else true) ,
	check_place(X-Y,Rest).

(From a basic n_queens problem solver.)
I get the error:

n_queens.m:069: In clause for predicate
`n_queens:check_place/2':
n_queens.m:069:   error: ambiguous overloading causes
type ambiguity.
n_queens.m:069:   Possible type assignments include:
n_queens.m:069: V_10 :: int or (pred int)

Where line 69 is the first line of the second clause
of check_place.  If I use -E it tells me to use an
explicit type qualification.  But surely the type of
the expressions in the head of the clause are
specified in the pred declaration.  To make sure, I
added an explicit type qualification for all the
variables in the head, which made no difference.

This seems to be an ambiguity between the '-'
predicate for ints, and the pair operator.  I've tried
every way I can think of of explicitly declaring that
it is the pair operator, with no result.

Can anyone here help me?

Thanks, Dave Slutzkin.
Benjamin St, Parkville, Melbourne, Australia.

--
Email can be sent to
dave_slutzkin at yahoo.com
OR
dcs at students.cs.mu.oz.au

_____________________________________________________________________________
http://messenger.yahoo.com.au - Yahoo! Messenger
- Voice chat, mail alerts, stock quotes and favourite news and lots more!
--------------------------------------------------------------------------
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