Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
QuasiQuotes (QQ) are a minor extension of Template Haskell that let us embed arbitrary content
within our Haskell source files. For example, we mentioned previously the
hamletFile TH function, which reads the template contents from an external
file. We also have a quasi-quoter named hamlet that takes the content
inline:
{-# LANGUAGE QuasiQuotes #-}[hamlet|<p>Thisisquasi-quotedHamlet.|]
The syntax is set off using square brackets and pipes. The name of the quasi-quoter is given between the opening bracket and the first pipe, and the content is given between the pipes.
Throughout the book, we will often use the QQ approach over a TH-powered external file since the former is simpler to copy and paste. However, in production, external files are recommended for all but the shortest of inputs as it gives a nice separation of the non-Haskell syntax from your Haskell code.