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

GHC ghc-devs at haskell.org
Fri Apr 24 01:22:41 UTC 2015


#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


More information about the ghc-tickets mailing list