Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Documentation
interpExp :: String -> Q Exp Source #
interpExp
performs very simple interpolation of Haskell
values into String
s.
- Interpolated variables are prefixed with
$
- They can optionally be surrounded with braces like
${foo}
- Interpolated variables are converted to strings with
show
- To escape a
$
use\$
>>>
let foo = 123 in $(interpExp "hello, $foo")
"hello, 123"
>>>
let foo = "world" in $(interpExp "hello, \\$foo")
"hello, $foo"
>>>
let foo = "world" in $(interpExp "hello\r\n\rworld")
"hello\r\n\rworld"