[Haskell-cafe] Type checking the content of a string
Corentin Dupont
corentin.dupont at gmail.com
Fri Feb 22 19:43:51 CET 2013
Hi Adam,
that looks interresting. I'm totally new to TH and QuasiQuotes, though.
Can I run IO in a QuasiQuoter? I can run my own interpreter.
On Fri, Feb 22, 2013 at 7:12 PM, adam vogt <vogt.adam at gmail.com> wrote:
> On Fri, Feb 22, 2013 at 12:44 PM, Corentin Dupont
> <corentin.dupont at gmail.com> wrote:
> > 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130222/9a19ceeb/attachment.htm>
More information about the Haskell-Cafe
mailing list