interpolate-0.2.1: String interpolation done right

Safe Haskell | None
Language | Haskell2010

Data.String.Interpolate

Contents

- String interpolation done right

Synopsis

- i :: QuasiQuoter

# 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 :: QuasiQuoter Source #

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