summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Feuer <david.feuer@gmail.com>2022-10-03 20:24:12 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-10-21 03:00:00 -0400
commite3b3986e2f06880114644069da797201ee0a53cb (patch)
tree3b63133c858037c2171f7b4095d69ac518fa3e37
parent1fe7921c283ccd4048fd6c1e410100e3953e2710 (diff)
downloadhaskell-e3b3986e2f06880114644069da797201ee0a53cb.tar.gz
Document how to quote certain names with spaces
Quoting a name for Template Haskell is a bit tricky if the second character of that name is a single quote. The User's Guide falsely claimed that it was impossible. Document how to do it. Fixes #22236
-rw-r--r--docs/users_guide/exts/template_haskell.rst15
1 files changed, 8 insertions, 7 deletions
diff --git a/docs/users_guide/exts/template_haskell.rst b/docs/users_guide/exts/template_haskell.rst
index f5285e69b3..f4f95fedf5 100644
--- a/docs/users_guide/exts/template_haskell.rst
+++ b/docs/users_guide/exts/template_haskell.rst
@@ -159,13 +159,14 @@ The :extension:`TemplateHaskellQuotes` extension is considered safe under
general ``'``\ ⟨thing⟩ interprets ⟨thing⟩ in an expression
context.
- A name whose second character is a single quote (sadly) cannot be
- quoted in this way, because it will be parsed instead as a quoted
- character. For example, if the function is called ``f'7`` (which
- is a legal Haskell identifier), an attempt to quote it as ``'f'7``
- would be parsed as the character literal ``'f'`` followed by the
- numeric literal ``7``. There is no current escape mechanism in
- this (unusual) situation.
+ A name whose second character is a single quote cannot be quoted in
+ exactly this way, because it will be parsed instead as a quoted
+ character. For example, if the function is called ``f'7`` (which is a
+ legal Haskell identifier), an attempt to quote it as ``'f'7`` would be
+ parsed as the character literal ``'f'`` followed by the numeric literal
+ ``7``. As for promoted constructors (:ref:`_promotion-syntax`), the
+ workaround is to add a space between the quote and the name. The name of
+ the function ``f'7`` is thus written ``' f'7``.
- ``''T`` has type ``Name``, and names the type constructor ``T``.
That is, ``''``\ ⟨thing⟩ interprets ⟨thing⟩ in a type context.