[GHC] #5972: option to suppress (Monomorphic) record selector functions

GHC ghc-devs at haskell.org
Wed Sep 7 00:07:43 UTC 2016


#5972: option to suppress (Monomorphic) record selector functions
-------------------------------------+-------------------------------------
        Reporter:  AntC              |                Owner:
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:
      Resolution:                    |             Keywords:  records
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 AntC):

 Hi Matthew, I guess this whole ticket has been overtaken by the
 DuplicateRecordFields extension in GHC 8.0. This ticket was written way
 before SPJ and Adam arrived at that approach. There might still be some
 lensaholics who hanker after the namespace. For the record ...

 > A field label and record selector are currently the same thing.

 You might think that because they are spelt the same, and one always comes
 with the other under H98, but actually as at H98 they're not. And that's
 the point:

 * a record selector is a function, first-class. If the language didn't
 create one automatically, you could do it yourself.
 * a field label can only appear in specific record access contexts {inside
 curly braces}. It is not first-class; only syntax sugar for positional
 access to the fields of the constructor.

 I agree there are namespace concerns if a user creates their own function
 with the same name (which is indeed the purpose). This chiefly affects
 module export/import. See the link in the OP for more detail.

 > It would seem that a correct solution would place field labels in a
 separate namespace ...

 I believe the pre-DuplicateRecordFields implementation unsugarred the
 field labels so they didn't occupy a namespace atall. Perhaps the
 situation is now different with Overloaded labels.

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


More information about the ghc-tickets mailing list