HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleshakespeare-2.1.0.1Haskell2010

Text.Shakespeare.Text

A Shakespearean module for general text processing, introducing type-safe, compile-time variable interpolation.

Text templates use the same parser as for other shakespearean templates which enables variable interpolation using #{..}. The parser also recognize the @{..} and ^{..} syntax.

If it is necessary that your template produces the output containing one of the interpolation syntax you can escape the sequence using a backslash:

λ> :set -XQuasiQuotes
λ> let bar = 23 :: Int in [st|#{bar}|] :: Text

produces "23", but

λ> let bar = 23 :: Int in [st|#\{bar}|] :: Text

returns "#{bar}". The escaping backslash is removed from the output.

Further reading: Shakespearean templates: https://www.yesodweb.com/book/shakespearean-templates

  • 1 type
  • 1 class
  • 15 values
classclass ToText a where
#

Methods

Instances7ToText, …
  • ToText Int32Defined in shakespeare-2.1.0.1 · Text.Shakespeare.Text
  • ToText Int64Defined in shakespeare-2.1.0.1 · Text.Shakespeare.Text
  • ToText IntDefined in shakespeare-2.1.0.1 · Text.Shakespeare.Text
  • ToText TextDefined in shakespeare-2.1.0.1 · Text.Shakespeare.Text
  • ToText BuilderDefined in shakespeare-2.1.0.1 · Text.Shakespeare.Text
  • ToText TextDefined in shakespeare-2.1.0.1 · Text.Shakespeare.Text
  • ToText [Char]Defined in shakespeare-2.1.0.1 · Text.Shakespeare.Text
valuestext :: QuasiQuoter
#

"Simple text" quasi-quoter. May only be used to generate expressions.

Generated expressions have type Text.

>>> do let x = "world"
       putStrLn [stext|Hello, #{x}!|]
Hello, world!

strict text

lazy text, same as stext :)

strict text whose left edge is aligned with bar (|)

lazy text, whose left edge is aligned with bar (|) * Yesod code generation

valuecodegen :: QuasiQuoter
#

codegen is designed for generating Yesod code, including templates So it uses different interpolation characters that won't clash with templates. You can use the normal text quasiquoters to generate code

valuecodegenSt :: QuasiQuoter
#

Generates strict Text codegen is designed for generating Yesod code, including templates So it uses different interpolation characters that won't clash with templates.