Quoting a quasi-quote

Yitzchak Gale gale at sefer.org
Thu Jun 30 15:52:23 CEST 2011

It was pointed out by Ben Millwood on the Cafe
that there is an undocumented way to escape the
closing oxford bracket of a quasi-quote using
a backslash:

[s|This quasi-quote contains this, \|], an escaped
closing oxford bracket.|]

The backslash itself cannot be escaped in this

[s|Also contains an escaped bracket \\|] |]

Thus there is a fairly strong limitation on the
contents of a quasi-quote: it can never end
in a backslash.

This behavior is not mentioned in the GHC docs.
Is it a mistake, or is it meant to be a supported

This behavior is a bit surprising to me. Since the
whole point of a quasi-quoter is to allow the user
to define syntax, you would think that the syntax
for the quasi-quote itself would be as quiet as
possible and stay out of the way. People who
need to be able to escape the closing bracket
can easily define their own syntax to do so.

In any case, if this is indeed a feature, it certainly
should be documented.


More information about the Glasgow-haskell-users mailing list