Safe Haskell | None |
---|---|
Language | Haskell2010 |
Yet another string interpolator
- Dead simple
- No dependency on haskell-src-meta. It is not actively developed, has long compile times and several bugs, some of which are by design (e.g. operator fixities).
- Supports interpolating
String
,Text
,Text
,ByteString
andByteString
(UTF8).
Synopsis
- i :: QuasiQuoter
- iFS :: QuasiQuoter
- iS :: QuasiQuoter
- iT :: QuasiQuoter
- iTL :: QuasiQuoter
- iB :: QuasiQuoter
- iBL :: QuasiQuoter
Documentation
i :: QuasiQuoter Source #
The main interpolator, intended to be used with
QuasiQuotes
.
>>>
:set -XQuasiQuotes
>>>
(foo, bar) = ("yet another ", "interpolator")
>>>
[i|${foo}string $bar|] :: String
"yet another string interpolator"
You can also use ${}
to create a function interpolator (this "abstraction" feature is inspired by
interpolate):
>>>
[i|more ${}${} code|] "point" "free" :: Text
"more pointfree code"
To use show
to interpolate a value:
>>>
let x = 1 + 1 in [i|1 + 1 = ${show x}|] :: ByteString
"1 + 1 = 2">>>
[i|2 + 2 = $show|] (2 + 2) :: Text
"2 + 2 = 4"
Variants
iFS :: QuasiQuoter Source #
Like i
, but works with IsString
.
[iFS
|...|] =fromString
[i
|...|]
>>>
:t [iFS|hi|]
[iFS|hi|] :: Data.String.IsString a => a
iS :: QuasiQuoter Source #
iT :: QuasiQuoter Source #
iTL :: QuasiQuoter Source #
Like iT
, but lazy.
iB :: QuasiQuoter Source #
Like i
, but with the result type fixed to ByteString
.
[iB
|...|] = [i
|...|] ::ByteString
>>>
:t [iB|hi|]
[iB|hi|] :: ByteString
iBL :: QuasiQuoter Source #
Like iB
, but lazy.