interpolate-0.0.4: String interpolation done right

Safe HaskellNone

Data.String.Interpolate

Contents

Synopsis

String interpolation done right

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

>>> :set -XQuasiQuotes
>>> import Data.String.Interpolate

i :: QuasiQuoterSource

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

It interpolates strings

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

or integers

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

or arbitrary Haskell expressions

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