- Expression example
- How it works
- The QuasiQuoter type
- The Q monad
- Relationship to Template Haskell
If you do not feel that Haskell’s syntax is suitable for the task at hand, quasi-quotation allows you to write, within your Haskell source code, miniature programs in some other language. When your Haskell program gets compiled, the mini-programs inside it get compiled as well.
Although this concept sounds rather extravagant, many of its applications are quite modest. Some uses of quasi-quotes include:The
modern-uri package provides quasi-quoters for writing URLs.
- Compile-time verification that URL and JSON literals are well-formedThe aeson-qq package provides quasi-quoters for writing JSON.
- Adding Haskell syntax features likeThe neat-interpolation package provides a quasi-quoter for building strings. string interpolation and multi-line strings.
QuasiQuotes extensionGHC documentation for
QuasiQuotes was introduced in GHC 6.10.1. At that time, quasi-quoters were only supported for expressions and patterns. The feature was expanded in GHC 7.0.1 to also include types and top-level declarations.