partial evaluation

Simon Peyton-Jones
Mon, 4 Feb 2002 03:25:43 -0800

If you say {-# INLINE f #-} on a fn defn for f, it'll get inlined at
all its call sites, which is sort of what you want.  Just saying=20
'evaluate this CAF to WHNF' might only inline the outer combinator.

Generally, some precise way of controlling what gets evaluated
at compile time, a bit less heavyweight than MetaML, would be a fine
thing.    After all that's what C++ templates are.=20

But the details of a workable design aren't clear to me.   Ideas?


| -----Original Message-----
| From: David Feuer []=20
| Sent: 01 February 2002 07:41
| To:
| Subject: partial evaluation
| Sensitivity: Confidential
| It seems to me that it might be useful (and probably=20
| fairly easy) to add to GHC a limited sort of partial=20
| evaluation: programmer-designated top-level CAFs could be=20
| evaluated to WHNF during compilation.  Termination of that=20
| compiler phase would obviously not be guaranteed, but if=20
| this were possible, I am guessing it would be very useful=20
| for some applications, such as combinator-based parsers. =20
| The parsers would then be generated at compiler time=20
| rather than re-generated every time the parser is=20
| executed.  If GHC in fact supports something of this=20
| nature, I would love to hear about it.  If it does not, I=20
| would guess it would probably be fairly easy to add to the=20
| end of the code generation phase.
| David Feuer
| This message has been brought to you by the letter alpha and=20
| the number pi.
| _______________________________________________
| Glasgow-haskell-users mailing list=20
|| haskell-users