Room: BBL room 471
Speaker: Gerrit van den Geest
Title: Typed Quote/Antiquote
We present work of Hinze  and Okasaki  about a systematic approach to embed languages in Haskell with a quote/antiquote mechanism. A quote/antiquote mechanism makes it possible to use the concrete syntax of a specific language inside a host language by enclosing it in quotes. Inside the quotation one can escape to the host language by using an antiquotation.
This technique can be used to embed Domain Specific Languages (DSLs) in Haskell. Domain Specific Languages have many benefits, like programs that are easier to understand and reason about. But the additional start-up costs of implementing a lexer, parser, compiler, and pretty-printer for a DSL, are often to high. We can lower those costs by embedding a DSL inside another language, this is called a Domain Specific Embedded Language (DSEL).
During the presentation we introduce an increasingly complex syntax for a combinator library expressing Financial Contracts (Peyton-Jones et al.). We start with postfix notation, prefix notation, and a grammar in Greibach Normal Form (GNF) for this DSEL. Then we proceed by implementing a syntax given by a LL(1), and a LR(0) grammar. We show how to translate those grammars to an implementation in Haskell. To accomplish this, we use: overloading, polymorphism and, higher order functions. Also techniques reminiscent of the continuation monad are used.
Presentation code and slides:
 Ralf Hinze. Functional Pearl: Typed Quote/Antiquote. Under consideration for publication in J. Functional Programming. (pdf
 Chris Okasaki. Techniques for embedding postfix languages in Haskell. Haskell '02: Proceedings of the 2002 ACM SIGPLAN workshop on Haskell. (pdf