[GHC] #13054: Generating unique names with template haskell

GHC ghc-devs at haskell.org
Tue Jan 3 18:24:01 UTC 2017


#13054: Generating unique names with template haskell
-------------------------------------+-------------------------------------
        Reporter:  tim-m89           |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Template Haskell  |              Version:  8.0.1
      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 goldfire):

 `newName` is intended for producing local names only, not anything top-
 level. I'm not surprised that it runs into trouble when you're using it at
 top-level. In a terrible horrible no-good workaround, my `th-desugar`
 library exports

 {{{
 -- | Like newName, but even more unique (unique across different splices),
 -- and with unique @nameBase at s. Precondition: the string is a valid
 Haskell
 -- alphanumeric identifier (could be upper- or lower-case).
 newUniqueName :: Quasi q => String -> q Name
 newUniqueName str = do
   n <- qNewName str
   qNewName $ show n
 }}}

 This should fix your problem but is a sad, sad thing.

 The whole `newName` facility needs an update. Waiting for copious free
 time to do so!

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


More information about the ghc-tickets mailing list