worldsayshi
worldsayshi

Reputation: 1991

Running Q Exp in a GhcMonad

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.

Upvotes: 2

Views: 80

Answers (0)

Related Questions