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

Modulestreamly-core-0.2.2Haskell2010

Streamly.Unicode.String

Convenient template Haskell quasiquoters to format strings.

The str quasiquoter retains newlines in the string when the line is split across multiple lines. The unwords . lines idiom can be used on the resulting string to collapse it into a single line.

  • 1 value

Setup

1 declaration

To execute the code examples provided in this module in ghci, please run the following commands first.

Example3 expressions
:m:set -XQuasiQuotesimport Streamly.Internal.Unicode.String
valuestr :: QuasiQuoter
#

A QuasiQuoter that treats the input as a string literal:

Example1 expression
[str|x|]"x"

Any #{symbol} is replaced by the value of the Haskell symbol symbol which is in scope:

Example2 expressions
x = "hello"[str|#{x} world!|]"hello world!"

## means a literal # without the special meaning for referencing haskell symbols:

Example1 expression
[str|##{x} world!|]"#{x} world!"

A # at the end of line means the line continues to the next line without introducing a newline character:

Example1 expression
:{[str|hello#world!|]:}"hello world!"

Bugs: because of a bug in parsers, a lone # at the end of input gets removed.