Ticket #4197 (closed task: fixed)

Opened 3 years ago

Last modified 14 months ago

clarify which names can not be quoted

Reported by: maeder Owned by:
Priority: low Milestone: 7.6.1
Component: Documentation Version: 6.12.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

http://www.haskell.org/ghc/docs/6.12.2/html/users_guide/template-haskell.html#id665813

I suppose a primed identifier like x' or T' can not be quoted, because they would be scanned as character.

Maybe all identifiers containing primes should be disallowed being quoted by one or two leading primes.

In any case, the documentation should match the implementation.

Change History

Changed 3 years ago by simonpj

Any chance you could send a documentation patch? Thanks!

Simon

Changed 3 years ago by maeder

Add: "Names containing primes can not be quoted if they would become legal haskell character literals."  http://www.haskell.org/onlinelibrary/syntax-iso.html#sect9.2 (char)

Any chance you disallow all names containing primes in the implementation just to increase the gap between a bad literal 'ab' and a difficult to read quote?

Changed 3 years ago by maeder

for a changed implementation add:

"Names containing primes can not be quoted in order to avoid confusion with character literals."

Changed 3 years ago by maeder

replace "primes" with "single-quotes"

Changed 3 years ago by igloo

  • milestone set to 6.14.1

Changed 2 years ago by igloo

  • milestone changed from 7.0.1 to 7.0.2

Changed 2 years ago by igloo

  • milestone changed from 7.0.2 to 7.2.1

Changed 20 months ago by igloo

  • milestone changed from 7.2.1 to 7.4.1

Changed 16 months ago by igloo

  • priority changed from normal to low
  • milestone changed from 7.4.1 to 7.6.1

Changed 15 months ago by maeder

http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/syntax-extns.html#syntax-stolen wrongly mentions -XPolyKinds in:

'varid
    Stolen by: -XTemplateHaskell and -XPolyKinds 

http://www.haskell.org/ghc/docs/7.4.1/html/users_guide/template-haskell.html

'f has type Name, and names the function f. Similarly 'C has type Name and names the data constructor C. In general 'thing interprets thing in an expression context. 

should be extended: "Names f or C that form (or start with) a legal character if quoted, cannot be quoted."

Prelude> let a' = 1
Prelude> :t 'a'
'a' :: Char
Prelude> let ab' = 1
Prelude> :t 'ab'
'ab' :: Language.Haskell.TH.Syntax.Name
Prelude> let a'' = 1
Prelude> :t 'a''

<interactive>:1:5:
    lexical error in string/character literal at end of input
Prelude> let a'a' = 1
Prelude> :t 'a'a'

<interactive>:1:1:
    The function 'a' is applied to one argument,
    but its type `Char' has none
    In the expression: 'a' a'

Changed 14 months ago by simonpj@…

commit 0936621a72da0e8811d351be6f03edd5d724f711

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Fri Mar 16 16:12:31 2012 +0000

    Fix documentation about TH and kind-promotion single-quote notation (Trac #4197)

 docs/users_guide/glasgow_exts.xml |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

Changed 14 months ago by simonpj

  • difficulty set to Unknown

Actually neither TH nor PolyKinds steal 'x or 'T:

  • In a character literal 'x', the character literal wins both times.
  • If you have just 'x all by itself, it's rejected unless you have PolyKinds or TemplateHaskell.

So the meaning never changes; nothing is stolen. So I will

Changed 14 months ago by simonpj

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.