準クォーターr
は補間を実装していません。生の文字列専用です。別の準引用符が必要です。
完全なコード:
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
import Data.Text (Text)
import Text.RawString.QQ (r)
import NeatInterpolation (text)
rQuote :: Text -> Text
rQuote myVariable = [r|line one
line two
line tree
${ myVariable }
line five|]
neatQuote :: Text -> Text
neatQuote myVariable = [text|line one
line two
line tree
$myVariable
line five|]
rText, neatText :: Text
rText = rQuote "line four"
neatText = neatQuote "line four"
でghci
:
*Main> import Data.Text.IO as TIO
*Main TIO> TIO.putStrLn rText
line one
line two
line tree
${ myVariable }
line five
*Main TIO> TIO.putStrLn neatText
line one
line two
line tree
line four
line five