Hi all,
I have a program able to read another program as a string, and interpret it (using Hint).
I'd like to make unit tests, so I have a file "Test.hs" containing a serie of test programs as strings.
However, how could I be sure that these test program are syntactically valid, at compile time?
Those programs should have the type "RuleFunc".
I tried some TH:
printProg :: Q Exp -> String
printProg p = unsafePerformIO $ do
expr <- runQ p
return $ pprint expr
myTest = printProg [| <my test program> :: RuleFunc |]
But it's not very satisfatory yet. When pretty printing TH changes the program quite a bit and my interpreter cannot compile it due to scoping problems.
I'd like to have my test program copied back as is. Is it possible? Any other solutions?
Thanks a lot!
Corentin