[GHC] #10796: Illegal data constructor name: `fromList' ... When splicing a TH expression

GHC ghc-devs at haskell.org
Thu Oct 8 18:54:31 UTC 2015


#10796: Illegal data constructor name: `fromList' ... When splicing a TH expression
-------------------------------------+-------------------------------------
        Reporter:  erisco            |                Owner:  RyanGlScott
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:  8.0.1
       Component:  Template Haskell  |              Version:  7.8.3
      Resolution:                    |             Keywords:  newcomer
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D1313
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 On the discussion for Phab:D1313, Richard noted that in order to fix this
 bug properly, it would be necessary for `template-haskell` to know
 precisely which identifiers correspond to variables, and which correspond
 to data constructors. This can be surprisingly tricky, since a litmus test
 for variables vs. constructors must take into account infix symbols and
 special characters (e.g., [https://ghc.haskell.org/trac/ghc/ticket/1103
 Japanese katakana or hiragana]).

 Such a task seems best left to a function separate from `dataToQa`, but
 which one? There's
 [https://git.haskell.org/ghc.git/blob/ea4df12f7f3fc4d1d2af335804b8ec893f45550c:/compiler/basicTypes/Lexeme.hs#l90
 startsVarSym, startsVarId, startsConSym, and startsConId] from `Lexeme` in
 GHC, but `template-haskell` can't depend on GHC. We ought not move these
 to `base` either, since that we need this functionality to compile stage
 1.

 Therefore, it seems apt to move this to a package which both `ghc` and
 `template-haskell` could depend on. Luckily, there's some momentum behind
 this already: Simon PJ [https://phabricator.haskell.org/D1200#33621
 suggested] reappropriating the `bin-package-db` package to become a
 library which contains functionality that is needed across multiple GHC
 boot libraries (including GHC itself). Less fortunately, we'd probably
 need to give it a new name to reflect this.

 Here is what I propose to resolve this quagmire:

 1. Rename `bin-package-db` to `ghc-common` (other naming suggestions are
 welcome).
 2. Move `startsVarSym`, `startsVarId`, `startsConSym`, `startsConId`,
 `startsVarSymASCII`, and `isVarSymChar` from `Lexeme` to `ghc-common`.
 There are other things that could be moved, but these would be enough to
 fix this ticket, and don't rely on a GHC internal data type (e.g.,
 `FastString`).
 3. Make `ghc` and `template-haskell` depend on `ghc-common`. No other
 changes to `ghc` should be necessary.
 4. Use `startsVarSym` and `startsVarId` to check if a string corresponds
 to a variable name within `template-haskell`.

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


More information about the ghc-tickets mailing list