#5348: Template Haskell quasiquote escapes
---------------------------------+------------------------------------------
Reporter: simonpj | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.0.3
Keywords: | Testcase:
Blockedby: | Difficulty:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
Comment(by JonasDuregard):
Replying to [comment:10 simonpj]:
> where the "`blah blah`" is in the PADS DSL, but then there's a bit of
proper Haskell inside. Now that proper Haskell is parsed with, well, a
Haskell parser. So if she want the sequence "|]" in that literal string,
what should she do?
I think what benmachine means by library support is a function like
{{{
escaped :: QuasiQuoter -> QuasiQuoter
}}}
That takes any quoter and produces a new one which preprocesses the input
string, replacing [\| with [|. Ideally we could then write [escaped q|blah
|\] blah|], but this requires a relaxed syntax for quoter identifiers.
Currently we must use q' = escaped q and [q'|...]. And i believe q' must
be defined in a separate module.
I think this solution is great, text is used verbatim unless the user
decides to go with a modified quoter (and this should only be done if the
verbatim quoter gives a parse error). This way the user only needs to
worry about escaping in the very rare occasions when a |] is in the quoted
text. Of course if you need both |\] and |] in your text you can use a
preprocessor with a more advanced escaping mechanism, with the
disadvantage that you need to be more careful with the rest of your text
'''but only in this particular quote'''!
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5348#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs