#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
---------------------------------+------------------------------------------
Changes (by JonasDuregard):
* cc: jonas.duregard@… (added)
Comment:
I posted this suggestion on the GHC users list, should probably just have
posted it here instead:
We introduce an alternative start tag i.e. a quote can start with [q| or
[q\| (or something similar). If [q| is used then the quoted text is used
verbatim and if the alternative start-tag is used then the escape
sequences suggested (\\ and \|]) are enabled.
Examples:
These are all as in the current implementation:[[BR]]
[q|nothing special|][[BR]]
[q|a \ in the text|] (uses "a \\ in the text")[[BR]]
These is an incompatible change:[[BR]]
[q|a \|] |] will be a parse error, is currently "a |] "
These are all parse errors (I believe) that will work:[[BR]]
[q|a \|] will use "a \\"[[BR]]
[q\|nothing special|] will use "nothing special"[[BR]]
[q\|a \\ in the text|] will use "a \\ in the text"[[BR]]
[q\|both \|] and \\|] will use "both |] and \\"[[BR]]
Also [q\|a \ in the text|] should be a parse error, i.e. all backslashes
must be escape sequences when using the alternative tag.
Arguably the incompatible change could be removed, but then the
alternative tag must be used to end a quote with backslash and it seems
cleaner to have one fully verbatim and one fully escapable tag.
One advantage of this approach is that we can add more escape sequences in
the future without breaking code (since all backslash sequences are
reserved in the alternative tag).
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5348#comment:6>
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