Typed Quote/Antiquote—Or: Compile−time Parsing

Haskell is often used as a host language for embedding other languages. Typically, the abstract syntax of the guest language is defined by a collection of data type declarations; parsers and pretty-printers convert between the concrete syntax and its abstract representation. A quote/antiquote mechan...

Mô tả đầy đủ

Chi tiết về thư mục
Tác giả chính: Hinze, R
Định dạng: Journal article
Được phát hành: 2011
Miêu tả
Tóm tắt:Haskell is often used as a host language for embedding other languages. Typically, the abstract syntax of the guest language is defined by a collection of data type declarations; parsers and pretty-printers convert between the concrete syntax and its abstract representation. A quote/antiquote mechanism permits a tighter integration of the guest language into the host language by allowing one to use phrases in the guest language's concrete syntax. A quote/antiquote mechanism usually requires an extension of the host language. The purpose of this pearl is to show that one can program such a mechanism within Haskell itself. The technique is based on Okasaki's flattening combinators.