[GHC] #15284: Can't parse ''(*) in GHC HEAD

GHC ghc-devs at haskell.org
Sun Jun 17 20:05:19 UTC 2018


#15284: Can't parse ''(*) in GHC HEAD
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  highest           |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.5
  (Parser)                           |
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by int-index):

 That is because with `-XStarIsType`, `*` is treated as an alphanumeric
 identifier. You wouldn't expect something like this to work?

 {{{
 $ ghci -XTemplateHaskell
 GHCi, version 8.2.2: http://www.haskell.org/ghc/  :? for help
 Prelude> ''(Maybe)
 }}}

 What you write instead is:

 {{{
 Prelude> ''Maybe
 GHC.Base.Maybe
 }}}

 Treating it as an alphanumeric identifier is the correct thing to do, for
 instance it allows the following declaration which wasn't possible before
 (without parentheses):

 {{{
 $ inplace/bin/ghc-stage2 --interactive
 GHCi, version 8.5.20180616: http://www.haskell.org/ghc/  :? for help
 Prelude> data T = MkT * *
 }}}

 Now, you might argue that in this case it should be accepted without
 parentheses, `''*`, but it's not:

 {{{
 Prelude> ''*

 <interactive>:4:1: error:
     Parser error on `''`
     Character literals may not be empty
     Or perhaps you intended to use quotation syntax of TemplateHaskell,
     but the type variable or constructor is missing
 }}}

 This one does look like a bug to me. What I would expect instead is:

 {{{
 Prelude Data.Kind> ''Type
 GHC.Types.Type
 }}}

 I will fix if you agree that it's the way forward.

 In any case, you can workaround by full qualification:

 {{{
 Prelude GHC.TypeNats> ''(GHC.TypeNats.*)
 GHC.TypeNats.*
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15284#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list