[mercury-users] Question

Gustavo A. Ospina gos at info.fundp.ac.be
Fri Aug 20 21:29:45 AEST 1999

At 17:08 20/08/99 +1000, Maria Garcia de la Banda wrote:
>I am trying to define a predicate which among other things receives a
>function as first argument, applies something to it, and returns the
>resulting function. For example:
>:- mode out(T) :: new -> T.
>:- pred try(func(int,int)=int,int,func(int) = int).
>:- mode try(func(in,in) = out is det,in,out(func(in) = out is det)) is det.
>        Z = apply(X,Y).

I've try the solution

        Z = X(Y).

But the compiler still rejects this. It seems to be a problem in
unification of higher-order terms with higher order modes (but I don't have
a rigorous explanation). It seems to be necessary to express the
currification explicitely using lambda terms, like this :

try(X, Y, Z) :-
	Z = (func(A::in) = (B::out) is det :- B = X(Y, A)).

It compiles, but it shows there are something strange since the first
solutions didn't compile.

Hope this helps.

+ Gustavo.
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