Cheap and cheerful partial evaluation

Edward Z. Yang ezyang at MIT.EDU
Sun Aug 21 20:18:23 CEST 2011

Hello all,

It occurred to me that it might not be too difficult to use GHC's
optimization passes as a cheap and cheerful partial evaluator.

Consider some function we would like to partially evaluate:

    f = g h

Partial evaluation proceeds as follows: calculate the type of f,
inline and specialize g, inline and specialize h, and then optimize.
Effectively, laser-guided inlining.

With this (very) heavy hammer, we can, for example, solve the problem posed in, simply by ensuring all of our
"strict functions" are partially evaluated on the continuation handler
appropriately.  (This is not ideal, since we ought to be able to share the
strict worker/wrapper between instances, but might be a reasonable stop-gap for
some use cases.)

So, am I completely insane, or does this seem plausible and easy enough
to implement to make it into GHC?


More information about the Glasgow-haskell-users mailing list