QuasiQuotes
a conceptually simple but crucial extension
QuasiQuotes
allow you to drop arbitrary text inside [foo|
, |]
brackets, where foo
names your QuasiQuote
compiler.
foothing = [foo|
Here I can put anything I want as long as it isn't a '|'
immediately followed by a ']'. The String will be fed
through the 'foo' function at *compile time*, which can
reject the input to force a compilation error, or
generate some Haskell abstract syntax tree that will be
compiled and used in place of the quasi quote. They are
in effect a way to package up user-defined literals
which may implement arbitrary DSLs.
|]
The magic is explained in Quasiquotation 101.
Got an issue with any of this? Please share or drop me a line (see below).