[mercury-users] Idea for a currying library

Richard A. O'Keefe ok at hermes.otago.ac.nz
Mon Jan 17 09:31:01 AEDT 2000


Peter Schachte wrote:
	Richard goes on to recommend
                           *********	

What I wrote was that I "could well have recommended" something
"as a good-enough notation".  Note the tense!  I did *not* say that
I recommend it *now*. The very next sentence says '"sections" are great
for easy problems, but for hard ones, lambda-notation is so much easier
to get right.'  By "sections" I meant of course the Haskell notation
where
    (<)   = \x y. x < y
    (<z)  = \x  . x < z
    (z<)  = \y  . z < y
equivalent to
    (<)
    call_1_2(<,Z)
    call_2_1(Z,<)
respectively.  Frankly, "easy problems" in practice boils down to
"just one missing argument".

	> :- module(callperm, [
	>     %	call/1,
	> 
	> 	call_1/2,
	> 
	> 	call_1_2/3,
	> 	call_2_1/3,
	
	and so on...
	
	I agree that interfaces based on counting are not ideal, but both of
	these proposals are based on counting in one way or another,

Indeed.  I said as much myself.  I *also* said that after having used the
call_i_j_k stuff for a while I came to prefer lambda-notation.

	once
	both conventions are explained, I find
	
		maplist((#1 > 0), Numbers)
	
	very much clearer than
	
		maplist(call_2_1(>,0), Numbers)
	
The point of my message is that *neither* of them is clear.

	maplist((pred(X) => X > 0), Numbers)

is clearer by far than any counting notation at all.

	The only things I see to recommend the second approach over the first
	is that it's easier implement and doesn't require changing the
	language.

Precisely.  It meant I could try the idea out easily.  That persuaded me
that lambda-notation is better.  I provided callperm.pl so that other
people could have the same experience without waiting for language
changes that will in the end prove regrettable.

Peter Schachte's preferred notation shares one advantage with lambda
notation which the callperm stuff lacks:  the form that is abstracted
can be compound.  On the other hand, anything more than a single goal
is likely to merit a comment or two, so putting it on more than one
line is going to pay off in readability anyway and we might as well
use lambda-notation.
--------------------------------------------------------------------------
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