I am writing a Haskell command line program and using the lt quasiquoter ("lazy-text") from Text.Shakespeare.Text. In the Yesod book, it says that the hamlet quasiquoter ignores leading whitespace if the first non-whitespace character is a backslash (\).
Does this work in the lt quasiquoter?
My code looks like this:
[lt|Usage: #{programName} [OPTION ...]
\Version #{showVersion version}|]
but the output is
Usage: MyProg [OPTION ...]
\Version 0.1.0.0
with the Version string indented too far (and still containing the backslash). I also tried it with a space between the backslash and V.
Is this possible with shakespeare-text?
It doesn't appear to, however it isn't hard to add the feature yourself.
ltis just aQuasiQuoter, which is the data type:They take a
String, and return the appropriate template haskell type (depending on the context it is used in.It is a simple matter to transform a string so it works as you described with a regex:
Also, a function that transforms a
QuasiQuoterwith a string transform function is simple:Now you can make a version of
ltthat does what you need:Using it works as expected:
xevaluates to"Usage: SomeProgram [OPTIONS...]\nVersion 42.42.42"in ghci.