Feature request/help: evaluating template haskell at runtime
simonpj at microsoft.com
Wed May 23 05:53:39 EDT 2007
Perhaps you can just write a client to the GHC library that
- constructs a string for your program
- asks GHC to evaluate it just as if you'd typed it at the command line
You may say that a string is a silly thing -- your GA will construct a tree, so the GHC API should supply a function that takes the parse tree rather than the string. Good point. There should be a Trac feature request on which to accumulate feature requests for the GHC API.
But meanwhile, serialising it as a string should be fine, no?
| -----Original Message-----
| From: glasgow-haskell-users-bounces at haskell.org [mailto:glasgow-haskell-users-bounces at haskell.org] On
| Behalf Of Rene de Visser
| Sent: 20 May 2007 21:30
| To: glasgow-haskell-users at haskell.org
| Subject: Feature request/help: evaluating template haskell at runtime
| 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
| 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.
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users at haskell.org
More information about the Glasgow-haskell-users