[GHC] #11103: DuplicateRecordFields + TemplateHaskell

GHC ghc-devs at haskell.org
Tue Nov 17 16:45:33 UTC 2015


#11103: DuplicateRecordFields + TemplateHaskell
-------------------------------------+-------------------------------------
           Reporter:  adamgundry     |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.0.1
          Component:  Template       |           Version:  7.11
  Haskell                            |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 The [wiki:Records/OverloadedRecordFields/DuplicateRecordFields
 DuplicateRecordFields] extension works by mangling the Names of field
 selector functions, and treating fields specially in the renamer. Thus if
 you define
 {{{
 data T = MkT { foo :: Int }
 }}}
 then GHC will actually generate a selector called `$sel:foo:MkT`, but will
 resolve `foo` to refer to this selector.

 In general we want this name-mangling to be internal only, but at the
 moment it is visible when using Template Haskell, because the TH AST
 doesn't have a way to represent the distinction between the selector name
 and the field label. For example, if you reify `''T` above and then
 pretty-print it you will currently get
 {{{
 data T = MkT { $sel:foo:MkT :: Int }
 }}}
 which is obviously bad.

 I'm not sure how best to address this. We could represent the name as
 `mkNameG_v pkg mod "foo"`, which will look okay when inspected, but if it
 is subsequently reified it might be ambiguous. Should we add a new
 `NameFlavour`?

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


More information about the ghc-tickets mailing list