Feature request/help: evaluating template haskell at runtime

Rene de Visser Rene_de_Visser at hotmail.com
Sun May 20 16:29:46 EDT 2007


Hello,

I am attempting some genetic programming in Haskell.

Rather than defining my own data type for programs and writing my own 
interpreter, I want to use the template haskell expression data types and 
evaluate them with the rts's byte code interpreter. This gives me a nice 
fast interpreter that provides the statistics that I want.

I could pretty print the template haskell and then execute the result string 
using the GHC module or hs-plugins, but I would like to save the pretty 
printing and parsing as normally the program generation time is important by 
GP.

I have being looking at module TcSplice.

I see that I need to run the TH expression through function convertToHsExpr, 
but after that I am stuck.

This produces LHsExpr RdrName and I need to get CoreSyn.CoreExpr.

What functions to use?

dsLExpr :: LHsExpr Id -> DsM CoreSyn.CoreExpr seems one important step,
but I haven't figured out how to get from LHtsExpr RdrName to LHsExpr Id.

It would be nice to have standard GHC functionality to have the ability to 
compile and evaluate template haskell at runtime using the GHC library.

Rene. 





More information about the Glasgow-haskell-users mailing list