2

I'm looking for something with a type similar to this:

runQExpDynamically :: (GhcMonad m) => Q Exp -> m Dynamic

Docs: GhcMonad, Q Exp, Dynamic,

I'm looking for ways to combine two of my code examples; one for dynamically evaluating haskell code and one for composing haskell dynamically using template haskell. In other words run Q Exp:ressions in a GhcMonad.

I will work on this problem and I should document here as I go.

Some ideas

The approach that I currently find workable is to serialize the expression and feed it into the dynamic evaluation. The serialization will have to be done inside the Q monad somehow. I might be able to use that Exp implements the Ppr prettyprinter class. However, I might loose some type safety this way? There might be a cleaner (more hygenic"?) way. I should look a bit more into Data.Dynamic to understand how dynamic values work.

edit: I realize now that Dynamic only represent values, while I want to run Q Exp 'declarations'. I want to add datatypes to a dynamic context.

worldsayshi
  • 1,788
  • 15
  • 31
  • It seems like [this answer](http://stackoverflow.com/a/14460095/439034) more or less does this using the serialization approach. But it might be possible to do it in a more hygienic way. – worldsayshi Oct 25 '14 at 13:49

0 Answers0