[Git][ghc/ghc][master] 2 commits: Document how to quote certain names with spaces

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Fri Oct 21 07:00:20 UTC 2022



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
e3b3986e by David Feuer at 2022-10-21T03:00:00-04:00
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
- - - - -
0eba81e8 by Krzysztof Gogolewski at 2022-10-21T03:00:00-04:00
Fix syntax
- - - - -


1 changed file:

- docs/users_guide/exts/template_haskell.rst


Changes:

=====================================
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.



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1fe7921c283ccd4048fd6c1e410100e3953e2710...0eba81e8b02cb964cd1be5a6161e81eef3ef5870

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/1fe7921c283ccd4048fd6c1e410100e3953e2710...0eba81e8b02cb964cd1be5a6161e81eef3ef5870
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20221021/5f4a5dcd/attachment-0001.html>


More information about the ghc-commits mailing list