Skip to content

DuplicateRecordFields + TemplateHaskell

The 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?

Trac metadata
Trac field Value
Version 7.11
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information