HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleinterpolate-0.2.1Haskell2010

Data.String.Interpolate

  • 1 value

String interpolation done right

1 declaration

The examples in this module use QuasiQuotes. Make sure to enable the corresponding language extension.

Example2 expressions
:set -XQuasiQuotesimport Data.String.Interpolate
valuei :: QuasiQuoter
#

A QuasiQuoter for string interpolation. Expression enclosed within #{...} are interpolated, the result has to be in the Show class.

It interpolates strings

Example2 expressions
let name = "Marvin"putStrLn [i|name: #{name}|]name: Marvin

or integers

Example2 expressions
let age = 23putStrLn [i|age: #{age}|]age: 23

or arbitrary Haskell expressions

Example2 expressions
let profession = "\955-scientist"putStrLn [i|profession: #{unwords [name, "the", profession]}|]profession: Marvin the λ-scientist