[Haskell-cafe] Partial Evaluation

Bernie Pope bjpop at csse.unimelb.edu.au
Wed Mar 21 15:12:53 EDT 2007

I think you are confusing "partial application" and "partial evaluation".
Though they are conceptually related.

The former is what happens when you apply a function of arity N to M
arguments, where M < N. In Haskell the partially applied function is
suspended, pending the rest of its arguments.

The latter is a way of taking a program and _some_ of its inputs and
transforming/compiling/specialising it into a residual program, by
"evaluating" as much as possible, given the inputs you have available.

An interesting example of partial evaluation is to take an interpreter for a
language and a sample source program, and partially evaluate the interpreter
with respect to the program. The result is a version of the interpreter
which acts effectively as a compiled version of the source program.

In Hudak's paper(s), if I remember correctly, they have an interpreter for a
functional language (in continuation passing style), which is parameterised
by a monitor function. I think they are trying to argue that you can make
the system more efficient if you partially evaluate the interpreter with
respect to a particular monitor. It is better than running the interpreter
directly. The problem is that I think it is hard to scale to a language like
Haskell, though there might have been advances that I am not familiar with.

Wikipedia has an entry on partial evaluation which is somewhat useful,
though you should probably follow the references at the bottom.


> -----Original Message-----
> From: haskell-cafe-bounces at haskell.org [mailto:haskell-cafe-
> bounces at haskell.org] On Behalf Of jim burton
> Sent: 21 March 2007 18:47
> To: haskell-cafe at haskell.org
> Subject: [Haskell-cafe] Partial Evaluation
> I am reading Hudak's paper Modular Domain Specific Languages and Tools
> [1] and am confused by his use of the term `Partial Evaluation'. I
> understand it to mean supplying some but not all arguments to a
> function, e.g. (+3) but it seems to mean something else too. This is in
> the context of optimising performance:
> "We have used existing partial evaluation techniques to do
> this...Unfortunately, there does not currently exist a suitable,
> easy-to-use partial evaluator for Haskell. Our approach was to convert
> the Haskell program to Scheme, partially evaluate the Scheme program,
> and then translate back into Haskell."
> What does P.E, mean here?
> Thanks,
> [1] Available
> http://wiki.ittc.ku.edu/lambda/Image:Hudak-
> Modular_Domain_Specific_Languages_and_Tools.pdf
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list