Partial Evaluators / Specialiers in/for Haskell

John Hughes rjmh@cs.chalmers.se
Wed, 14 May 2003 12:27:34 +0200 (MEST)


On Tue, 13 May 2003, Jacques Carette wrote:

> I am looking for source code for any PE system, preferably written in
> Haskell for a Haskell-like (sub)language.  I am aware of "The Mini-Haskell
> Partial Evaluator" (see
> http://www.math.chalmers.se/~rjmh/PECourse/Exercises/PE.html), but it
> currently does not seem to work with recent version(s) of Haskell

It's in Haskell 1.3 and needs one or two small changes to bring it up to
date. This wouldn't be much work (but isn't high priority for me!).

> [nor does
> the web version seem to work, even on very simple examples].
>

It works for me. But it is tricky to use, because it has only a
binding-time CHECKER, and not a binding-time analyser. That means that you
personally have to insert all of the binding-time annotations, there are a
lot of them, and if you get one wrong then the specialiser doesn't work.
In the example that first appears when you start it, there are no
annotations (which is interpreted as: everything is dynamic), and
therefore no specialisation occurs. Here's what you have to write if you
want the usual specialisation of power:

The definition becomes
  	power n x = $if n$==$0 then 1 else x*power (n$-$1) x

The call to specialise becomes
	power $3 x

Adding a binding-time analyser would be a more substantial job.

> I am also aware of the extensive litterature, what I am really in search of
> is source code with a decent license :-).  Best of all would be some
> 'orphan' PE system where the author would like the system to grow, but does
> not have the time to do so -- I am looking at adopting...
>

The Mini-Haskell specialiser places the emphasis very firmly on Mini! I
wrote it just to support the course on partial evaluation that it
accompanies, so it is just powerful enough to do the exercises on that
course. And I chose a tiny subset of Haskell just so I could use a
familiar syntax. I doubt if it's what you're looking for.

John Hughes