[mercury-users] Higher-order predicates

Douglas Michael Auclair dauclair at hotmail.com
Fri May 31 03:52:56 AEST 2002


>From: Fergus Henderson <fjh at cs.mu.OZ.AU>
>>from me
> > main -->
> >   { Foof = pred(X::in, Z::out) is nondet :- foo(X, Z),
> > doesn't work either.

*blush* I just reviewed my sources, and there are the parentheses around the 
higher-order predicate definition as you write (I copied the sources 
incorrectly onto the email, sorry).  However, the error does not go away.  
Is this an issue with 0.10.1?  The program that has the error is below.

Sincerely,
Doug Auclair

% floop.m -- test of higher order predicates

:- module floop.
:- interface.
:- import_module io.

:- pred main(state, state).
:- mode main(di, uo) is det.

:- type bar ---> red; green; yellow.

:- implementation.
:- import_module std_util, list.

:- pred quux(bar, bar).
:- mode quux(in, out) is nondet.
:- mode quux(out, in) is nondet.

quux(red, green). quux(red, red). quux(red, yellow).
quux(green, green). quux(green, red).

:- pred foo(bar, bar).
:- mode foo(in, in) is semidet.
:- mode foo(in, out) is nondet.
:- mode foo(out, in) is nondet.

foo(X, Z) :- quux(X, Y), quux(Y, Z), X \= Z.

main -->
  { Foo = (pred(X::in, Z::out) is nondet :- foo(X, Z)),
    solutions(Foo(red), Colors) }, % compiler error thrown here
  print_list(Colors).

:- pred print_list(list(bar), state, state).
:- mode print_list(in, di, uo) is det.
print_list([]) --> [].
print_list([H|T]) --> write(H), print_list(T), nl.


_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
--------------------------------------------------------------------------
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