Re: [Haskell-cafe] code generation

Sorry for referring to a post, a bit ago.
http://www-users.cs.york.ac.uk/~ndm/derive/ (Deriving Generic Functions by Example).
Thanks for the pointer, it was already on my to-read-pile :-)
I think using Template Haskell for your work would fit very nicely, so is a good choice to learn :-)
I already got used to TH a bit, but I am not sure if it is appropriate for my purpose, or at least not completely. I want to load Haskell code into my program at runtime in an abstract representation (as TH), modify it and then type-check it or coerce it into a value (or execute it). For me it looks like I need a combination of Hint and TH. However, Hint can only interpret strings and to get a string from a QExp I have to enter the IO Monad using runQ. So, wouldn't it deteriorate my performance to do it all in the IO? Is there another way? Thanks, Martin

I think using Template Haskell for your work would fit very nicely, so is a good choice to learn :-)
I already got used to TH a bit, but I am not sure if it is appropriate for my purpose, or at least not completely.
I want to load Haskell code into my program at runtime in an abstract representation (as TH), modify it and then type-check it or coerce it into a value (or execute it). For me it looks like I need a combination of Hint and TH.
Perhaps. You might be able to use the GHC API to get some of what you want too.
However, Hint can only interpret strings and to get a string from a QExp I have to enter the IO Monad using runQ. So, wouldn't it deteriorate my performance to do it all in the IO? Is there another way?
I wouldn't worry about performance just yet. In general, Haskell code in the IO Monad is just as efficient as normal code - the IO Monad gets almost entirely optimised away by GHC. Thanks Neil ============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ==============================================================================
participants (2)
-
Martin Hofmann
-
Mitchell, Neil