[Haskell-cafe] Type checking the content of a string
Corentin Dupont
corentin.dupont at gmail.com
Fri Feb 22 18:44:06 CET 2013
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130222/a351a917/attachment.htm>
More information about the Haskell-Cafe
mailing list