[mercury-users] The Logic of Mercury

Peter Schachte schachte at cs.mu.OZ.AU
Thu Sep 9 17:37:57 AEST 1999


On Wed, Sep 08, 1999 at 12:44:25PM +1200, Richard A. O'Keefe wrote:
> - in my experience with SML, Haskell, and Clean, I have found that
>   about half of the partial applications I want in practice are NOT
>   supported by currying so that I have to use currying combinators
>   or explicit lambda-expressions, so that curried Mercury would only
>   save about half of the notational effort

I agree with Richard that currying, while pretty, is often not useful
in higher-order logic programs.  A more general solution to
conveniently creating closures would be preferable.

Several months ago, someone proposed a simple syntactic extension to
Mercury that would accomplish this -- sorry I've forgotten who it was
or which list it was on.  I also don't remember the details, but I'll
make up them as I go along.  The basic idea was to express a closure
by writing a goal (or functional expression) with special tokens
indicating where to put which non-curried arguments.  Eg, you might
write

	map(append(#1,Tail,#2), Heads, Lists)

to append Tail to every element of Heads giving Lists.  You could also
write

	filter((#1 >= 7, #1 =< 10), List, Inrange)

to bind Inrange to all the elements of List between 7 and 10.

I think this syntax is rather intuitive and readable, it allows any
arguments to be curried or not, and it works well for both functional
and relational syntax.  The only trouble with it is that it doesn't
solve the problem that IMHO makes higher order programming in Mercury
messy:  having to explicitly specify modes and a determinism for every
closure.  Until that problem is solved, I don't think questions of
apply/3 vs. call/N are very important.


-- 
Peter Schachte                     What is the robbing of a bank compared to
mailto:schachte at cs.mu.OZ.AU        the founding of a bank?
http://www.cs.mu.oz.au/~schachte/      -- Bertold Brecht 
PGP: finger schachte at 128.250.37.3  
--------------------------------------------------------------------------
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