How can I interpolate like this:
{-# LANGUAGE QuasiQuotes #-}
import Text.RawString.QQ
myText :: Text -> Text
myText myVariable = [r|line one
line two
line tree
${ myVariable }
line five|]
myText' :: Text
myText' = myText "line four"
${ myVariable }
prints as a literal, not an interpolation, can I do something similar that to interpolate in this case?
Quasi quoter
r
doesn't implement interpolation. It's only for raw strings. You need another quasi quoter.Complete code:
In
ghci
: