Is it possible to generate and run TemplateHaskell generated code at runtime?
问题 Is it possible to generate and run TemplateHaskell generated code at runtime? Using C, at runtime, I can: create the source code of a function, call out to gcc to compile it to a .so (linux) (or use llvm, etc.), load the .so and call the function. Is a similar thing possible with Template Haskell? 回答1: Yes, it's possible. The GHC API will compile Template Haskell. A proof-of-concept is available at https://github.com/JohnLato/meta-th, which, although not very sophisticated, shows one general