[GHC] #10189: explicit promotions of prefix data constructors can't be parsed naturally

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.4 (Parser) | Operating System: Unknown/Multiple Keywords: | Type of failure: GHC rejects Architecture: | valid program Unknown/Multiple | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- When used as an infix operator, a data constructor is explicitly promoted simply with `'` prefixed, but when used as a prefix operator enclosed between `(` and `)`, it is explicitly promoted only with `'` put before `(`, not before the constructor. On the other hand, messages of GHC and GHCi indicate that a data constructor operator in a prefix form is promoted by putting `'` before the constructor! (as in `forall (k :: BOX) (k :: BOX). (':*)` below.) I believe that this is a matter of parsing. The parser should admit `(':*)` as well as `'(:*)` for the naturalness of the syntax. In a GHCi: {{{#!hs
:set -XDataKinds -XTypeOperators data a :* b = a :* b :kind! Int :* Int Int :* Int :: * = Int :* Int :kind! Int ':* Int Int ':* Int :: * :* * = Int ':* Int :kind! (:*) (:*) :: * -> * -> * = (:*) :kind! '(:*) '(:*) :: k -> k1 -> k :* k1 = forall (k :: BOX) (k :: BOX). (':*) :kind! (':*)
<interactive>:1:3: parse error on input ‘:*’ }}} (By the way I assume that Template Haskell quotes (`'function` and `''Type`) are parsed by the same mechanism as the one for the explicit promotion syntax. I hope both styles of quotes for prefix operators will be admitted because currently only the `'(` `''(` style is admitted.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.4 (Parser) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #10188 | -------------------------------------+------------------------------------- Changes (by Kinokkory): * related: => #10188 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.4 (Parser) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #10188 | -------------------------------------+------------------------------------- Comment (by goldfire): The Template Haskell quotes are unaffected. They appear only in terms, which has a separate parser. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Kinokkory Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 (Parser) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #10188 | -------------------------------------+------------------------------------- Changes (by Kinokkory): * owner: => Kinokkory * milestone: => 7.12.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Kinokkory Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 (Parser) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #10188 | -------------------------------------+------------------------------------- Comment (by goldfire): This is a hard call for me. While I agree that putting the tick inside the parens is better, I'm leery of having two different ways to say the same think, with no change in meaning. It just seems confusing. And, removing the current (outside-the-parens) notation would be a large disruption for little benefit. I vote: fix the pretty-printer to match the parser, but leave the parser alone. This makes me sad, but it seems better than the alternatives. By the way, also look at infix promoted alphanumeric constructors: {{{ data Foo = Bar Bool Bool type Baz = True '`Bar` False }}} Note where that tick goes. I hate it! But, I still vote against changing it. Just make sure the pretty-printer does the right thing. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Kinokkory Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 (Parser) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #10188 | -------------------------------------+------------------------------------- Comment (by simonpj): Would it really be so bad to change it so that the tick goes inside the parens? It'll only affect people using (a) promotion, (b) type operators, and (c) prefix use of same. I'd prefer just to get it right. I think of `':` as the name of the promoted constructor, and if you want it prefix you should wrap it in parens. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Kinokkory Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 (Parser) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #10188 | -------------------------------------+------------------------------------- Comment (by goldfire): If we go with comment:5, that doesn't provide much of a migration path. The change would affect anyone using symbolic constructors prefix ''and'' anyone using alphanumeric constructors infix. I agree that this affects a tiny segment of our users. Part of the reason I don't feel like we need to change this is that I'm foreseeing a future where `'` can scope over a bunch of constructors, like `'(Just (Succ Succ Zero))` and the `'` just signifies a namespace change. Call me ambivalent on this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Kinokkory Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 (Parser) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #10188 | -------------------------------------+------------------------------------- Comment (by simonpj): Ah well making `'` scope over a ''term'', not just a ''name'', is a whole new unexplored ball of wax. I'd rather make what we have fit together nicely, otherwise we pay now for a distant and uncertain future benefit. We can jump future bridges when we come to them. I don't think we have enough legacy code to make wibblification on existing packages into a serious problem. I suppose we could allow both forms for a while, but emit deprecation messages for the old one. But I don't think that even that is worth the trouble. Let's just make the change: * `(':)`, not `'(:)` * {{{`'Bar`}}}, not {{{'`Bar`}}}. Can someone do this? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Kinokkory Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 (Parser) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #10188 | -------------------------------------+------------------------------------- Comment (by goldfire): Yes, that would be a new unexplored ball of wax, and I don't intend to explore it tonight. But, how about this: allow all four forms mentioned above. I have two reasons: * No breakage of existing code. * It's conceivable that the quote-on-the-outside form (that is, the existing, stupid form) will make decent sense some day. But please don't do this if it's hard. I fully agree on not paying now for something that might not happen later. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Kinokkory Type: bug | Status: new Priority: normal | Milestone: 7.12.1 Component: Compiler | Version: 7.8.4 (Parser) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: GHC rejects | Test Case: valid program | Blocking: Blocked By: | Differential Revisions: Related Tickets: #10188 | -------------------------------------+------------------------------------- Old description:
When used as an infix operator, a data constructor is explicitly promoted simply with `'` prefixed, but when used as a prefix operator enclosed between `(` and `)`, it is explicitly promoted only with `'` put before `(`, not before the constructor.
On the other hand, messages of GHC and GHCi indicate that a data constructor operator in a prefix form is promoted by putting `'` before the constructor! (as in `forall (k :: BOX) (k :: BOX). (':*)` below.)
I believe that this is a matter of parsing. The parser should admit `(':*)` as well as `'(:*)` for the naturalness of the syntax.
In a GHCi:
{{{#!hs
:set -XDataKinds -XTypeOperators data a :* b = a :* b :kind! Int :* Int Int :* Int :: * = Int :* Int :kind! Int ':* Int Int ':* Int :: * :* * = Int ':* Int :kind! (:*) (:*) :: * -> * -> * = (:*) :kind! '(:*) '(:*) :: k -> k1 -> k :* k1 = forall (k :: BOX) (k :: BOX). (':*) :kind! (':*)
<interactive>:1:3: parse error on input ‘:*’ }}}
(By the way I assume that Template Haskell quotes (`'function` and `''Type`) are parsed by the same mechanism as the one for the explicit promotion syntax. I hope both styles of quotes for prefix operators will be admitted because currently only the `'(` `''(` style is admitted.)
New description: When used as an infix operator, a data constructor is explicitly promoted simply with `'` prefixed, but when used as a prefix operator enclosed between `(` and `)`, it is explicitly promoted only with `'` put before `(`, not before the constructor. On the other hand, messages of GHC and GHCi indicate that a data constructor operator in a prefix form is promoted by putting `'` before the constructor! (as in `forall (k :: BOX) (k :: BOX). (':*)` below.) I believe that this is a matter of parsing. The parser should admit `(':*)` as well as `'(:*)` for the naturalness of the syntax. In a GHCi: {{{#!hs
:set -XDataKinds -XTypeOperators data a :* b = a :* b :kind! Int :* Int Int :* Int :: * = Int :* Int :kind! Int ':* Int Int ':* Int :: * :* * = Int ':* Int :kind! (:*) (:*) :: * -> * -> * = (:*) :kind! '(:*) '(:*) :: k -> k1 -> k :* k1 = forall (k :: BOX) (k :: BOX). (':*) :kind! (':*)
<interactive>:1:3: parse error on input ‘:*’ }}} -- Comment (by Kinokkory): (Removed the mention about Template Haskell syntax.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Kinokkory Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 7.8.4 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: #10188 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * milestone: => 8.6.1 Comment: This is still horribly confusing and unexpected. I also don't think it's documented. I'm definitely in the "just fix it" camp. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Kinokkory Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 7.8.4 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: #10188 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by dfeuer): * cc: dfeuer (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10189: explicit promotions of prefix data constructors can't be parsed naturally -------------------------------------+------------------------------------- Reporter: Kinokkory | Owner: Kinokkory Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.4 (Parser) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: | Blocking: Related Tickets: #10188 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.6.1 => Comment: Removing milestone as there is currently no one actively working on this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10189#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC