[Haskell-cafe] Re: Newbie terminology for partial application
jon.fairbairn at cl.cam.ac.uk
Mon Aug 27 12:38:38 EDT 2007
Peter Verswyvelen <bf3 at telenet.be> writes:
> A while ago I confused "currying" with "partial
> application", which was pointed out by members of this
> community, and the wiki pages got adapted so that newbies
> like me don't make the same mistake twice ;) That's great.
> Anyway, at the risk of making mistakes again, I'm looking
> for good terminilogy when talking about "partial
> For example:
> -- uncurried form
> *f (x,y)* = -- whatever
> -- curried form
> *g x y *= f (x,y)
> -- partial application
> *h x *= g x
It's only a partial application because g takes more than
one argument; bear that in mind.
> But when writing text documents, I guess it is common to say
> "/g is curried/",
Actually, I don't think most haskell programmers would say
anything at all. Haskellers generally write functions in
curried (because partial application is useful), and use
the function uncurry :: (a -> b -> c) -> (a, b) -> c
when an uncurried version is needed.
> but is it also common to say /"g is partially applied"?
> /The latter sounds silly to a non-native speaker like
> myself... Or shouldn't it be?
Sounds OK to me, though again, I'm not sure I would say it
often. A partial application is just an application that
returns a function, and this is functional programming, so
it goes without saying!
> /And what is "application"? I guess it means that (g x y) is
> internally translated to ((g $ x) $ y) which is translated
> into (apply (apply g x) y) where apply is a primitive
Application is itself the primitive, and the notation for
application is juxtaposition (f x). It might help to have a
look at lambda-calculus (if you have a strong stomach for
abstraction; if you don't it'd just scare you off).
In lambda-calculus there are only four bits of syntax
(I'll use Haskell syntax):
abstraction: \ a -> T -- where T is a lambda term
application: M N -- where M and N are lambda terms
variable reference: v -- where v is just a name
grouping: (M) -- where M is a lambda term
It's possible to think of Haskell as being based on lambda
calculus. Application in Haskell is the same as application
in lambda calculus, abstraction in Haskell has patterns that
lambda calculus does not. The other two are the same.
Jón Fairbairn Jon.Fairbairn at cl.cam.ac.uk
More information about the Haskell-Cafe