[Haskell-cafe] Re: Currying and Partial Evaluation

Achim Schneider barsoap at web.de
Tue Jan 8 21:37:07 EST 2008


Derek Elkins <derek.a.elkins at gmail.com> wrote:

> On Wed, 2008-01-09 at 00:51 +0100, Achim Schneider wrote:
> > Fernando Rodriguez <frr149 at easyjob.net> wrote:
> > 
> > > 
> > > Hi,
> > > 
> > > Is currying in Haskell the same thing as Partial Evaluation
> > > (http://en.wikipedia.org/wiki/Partial_evaluation)? Am I getting
> > > partial evaluation for free just by using Haskell? 
> > > 
> > No, currying is this:
> 
> No, it is not.  This is partial application.  See the wiki page Neil
> referenced.
> 
Which works because of the functions being curried... of course, the
usage is to "partly" apply a function, which is not possible, as all
Haskell functions are, by default, curried, and thus only have one
parameter, which can either be applied or not.

Partial evaluation, OTOH, goes into the direction of laziness vs.
eagerness: Iff the compiler sees that a thunk is only dependent on data
known at compile-time, it may choose to evaluate this thunk already at
compile-time, if you're lucky and the compiler isn't lazy,

main = putStrLn $ show $ 1 + 2

might end up being

main = putStrLn "3"

in the object file.


-- 
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
signature prohibited. 



More information about the Haskell-Cafe mailing list