
22 Feb
2013
22 Feb
'13
6:12 p.m.
On Fri, Feb 22, 2013 at 12:44 PM, Corentin Dupont
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?
Hi Corentin, You could write the test programs like: test1 :: String test1 = [qq| x+1 == 3 |] Where qq is a QuasiQuoter you have to define. It could try to parse the string with http://hackage.haskell.org/package/haskell-src-exts, and if that succeeds, returns the original string. -- Adam