HORIZON HASKELLDocslts/ghc-9.14.x7a6c33e2026-10-12Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 7a6c33e · 2026-10-12

Moduleinterpolate-0.2.1Haskell2010

Data.String.Interpolate

Contents
  1. String interpolation done right
Synopsis
  • value i

String interpolation done right

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