Re: QuasiQuoting for declarations
Robert Greayer <[email protected]> Mon, 1 Dec 2008 21:31:00 -0800 (PST)
| Newsgroups | gmane.comp.lang.haskell.template |
|---|---|
| Message-ID | <[email protected]> |
Simon Peyton-Jones wrote:=0A=0A> Meanwhile, I gather you are using quasi-qu= otes. I=E2=80=99m interested=0A> to know about applications: what are you = using it for?=0A=0A(I assume this was a general query, hence my reply...)= =0A=0AI'm using it in testing... I have written an an interpreter for a (C-= like) language, and quasi-quotation makes the tests for the interpreter rea= d very nicely -- I express a short program in the 'native' language syntax = (within a quasi-quotation), and then a few lines of Haskell defining the ex= pected behavior of the program. Without quasiquotation, I'd either have to= store the 'native' programs in separate files or build them up as strings = (which means, in either case, I could get the syntax wrong and not know it = until I run the tests. And the tests are harder to read). It was close to= zero work to create the quasi-quoter, since I already had the parser handy= . (I did have to enhance it to handle antiquotation, which I needed to mak= e the tests easier to write).=0A=0AI've visions of using the same technique= for expressing tests (queries and expected replies) in the native syntax o= f a particular server I'm involved in developing, but have not done so yet.= =0A=0ARob=0A=0A=0A=0A