[mercury-users] Idea for a currying library

Michael Day mcda at cat.cs.mu.OZ.AU
Sun Jan 16 00:05:55 AEDT 2000


> If you expected P would be invoked without a supplied argument name,
> then this would work fine for closures expecting one argument, but
> when more than 1 argument is missing, you're back to the same old
> problem (but worse, since there's no natural argument order to
> determne which missing argument is which).

Hmm I assumed that the current argument ordering semantics would still
apply and argument naming would be used in calls specifically to ensure
clarity, or to protect against future argument changes, or for the
demonstrated use in currying.

Actually I see now that I described a system half way between the current
system (in which you can curry arguments from the right) and the proposed
numbering system (in which you can both curry from anywhere and reorder
arguments). Being able to specify arguments by name would let you curry an
arbitrary subset of the arguments to a predicate but would not permit
reordering of the arguments. Making it fairly irrelevant to the discussion
which specifically centrered on argument reordering. Sorry.

To refer back to the original example:

        >       P = foo(X, #2, Y, #1)
        >
        > would translate into
        >
        >       P = (func(A, B) = foo(X, B, Y, A))

My first attempt at translating this was:

:- pred foo(name : string, int : size, color : tuple, ratio : float).
...

	P = foo(name = X, color = Y)
 
but that expands to:

	P = (func(A, B) = foo(X, A, Y, B))
	
note that the two remaining arguments stay in their original order.

Perhaps a combination of the two currying proposals would be useful? I
find the #numeric notation easier to understand than working out which
function permuter function to use and argument reordering seems too useful
to give up.

Michael

--------------------------------------------------------------------------
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