Cheap and cheerful partial evaluation

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


And no sooner do I send this email do I realize we have 'inline' built-in,
so I can probably experiment with this right now...

Edward

Excerpts from Edward Z. Yang's message of Sun Aug 21 14:18:23 -0400 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
> http://hackage.haskell.org/trac/ghc/ticket/1349, 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?
> 
> Cheers,
> Edward



More information about the Glasgow-haskell-users mailing list