There is not much here yet. But bellow is an example and links to other string interpolation libraries.
>>> :set -XQuasiQuotes
>>> import Data.String.Interpolate
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
There are many other string interpolation libraries for Haskell, each with it's own set of limitations. Here is a short list, a more thorough analysis will follow.
- interpolatedstring-qq
(insterpolating
String
andText
does not really work, try e.g. strings that contain unicode) - interpolatedstring-perl6
(uses
IncoherentInstances
)
There are more at http://www.haskell.org/haskellwiki/Quasiquotation and http://packdeps.haskellers.com/reverse/haskell-src-meta.