Type checking the content of a string
2013-02-22 17:44:06 GMT
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!
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe <at> haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe