string-interpolate-0.2.0.0: Haskell string/text/bytestring interpolation that just works

Copyright(c) William Yao 2019
LicenseBSD-3
Maintainerwilliamyaoh@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellNone
LanguageHaskell2010

Data.String.Interpolate

Description

This module provides two quasiquoters, i and iii, which:

  • handle all of String/Text/ByteString, both strict and lazy
  • can interpolate into anything that implements IsString
  • can interpolate anything that implements Show
  • are Unicode aware
  • are fast
  • handle multiline strings

i leaves newlines and whitespace intact as they are in the source code, while iii collapses newlines/whitespace into single spaces, stripping leading/trailing whitespace as well.

As an example,

{-# LANGUAGE OverloadedStrings #-}

import Data.Text
import Data.String.Interpolate ( i )

λ> age = 33 :: Int
λ> name = "Tatiana" :: Text
λ> [i|{"name": "#{name}", "age": #{age}}|] :: String
>>> "{\"name\": \"Tatiana\", \"age\": 33}"

λ> [i|
Name: #{name}
Age: #{age}
|] :: String
>>> "\nName: Tatiana\nAge: 33\n"

See the README at https://gitlab.com/williamyaoh/string-interpolate/blob/master/README.md for more details and examples.

Documentation