[mercury-users] higher-order programming

Mark Brown mark at cs.mu.OZ.AU
Mon May 23 14:37:26 AEST 2005


On 22-May-2005, Peter Ross <pro at missioncriticalit.com> wrote:
> Can someone please remind me why it's not possible to write the
> following program, instead one must use the commented out line.
> 
> :- pred p(int::out) is det.
> 
> p(X) :-
>         F = f(1),
>         G = F(2),
>     	% G = (func(X1) = F(2, X1)),
>         X = G(3).
> 
> :- func f(int, int, int) = int.

Likewise you can't write:

	:- func f(func(int) = (func(int) = int)) = int.
	f(F) = F(1, 2).

but instead you have to call apply/N twice:

	f(F) = G(2) :- G = F(1).

I'm looking into a way of improving this situation, but it isn't a high
priority at the moment since there are simple (albeit klunky) workarounds
for both problems.

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