Brian's Waste of Time

Fri, 05 Mar 2004

Partial Application and Currying Questions

I am slowly becoming a functional programming weenie -- really cool stuff. A discussion came up on groovy-dev about how I implemented currying on closures in groovy -- it was pointed out that what I really did was partial-application.

A quick google search sort of reinforced this, but I am not sure the difference, so here is a shameless plea for explanation. Here is my current understanding (in gauche scheme):

(use rfc.http)
(use srfi-11)

(define http-get-body 
    (lambda (host file)
        (let-values (
            ((response head body) (http-get host file)))
            body)))

(define with-http-body 
    (lambda (host file func)
        (func (http-get-body host file))))

(define with-ojb 
    (lambda (func)
        (with-http-body "db.apache.org" "/ojb/index.html" func)))

(with-ojb 
    (lambda (body)
        (display body)))

I think with-ojb is partial application as it provides two of the three arguments required by with-http-body and returns a function which takes the last. If that is the case, what is currying? Until today I thought that was currying. The wikipedia seems to say this is currying, but it seems to fit exactly the haskell definition of partial application -- and the examples on the wikipedia look very different.

Help?

3 writebacks [/src] permanent link