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