Overloaded record fields meta-ticket
This is a meta-ticket covering the ongoing work on The Records Problem, in particular related to DuplicateRecordFields
, NoFieldSelectors
and RecordDotSyntax
. See also issues labelled OverloadedRecordFields and the overloaded-record-fields wiki page.
The following pieces have implementations in flight:
-
Adding setField
toGHC.Records
(#16232, ghc-proposals#158). Implemented by @adamgundry (!3257) but stalled due to performance concerns. Planned next steps are documented at !3257 (comment 312762). @adamgundry has opened a GHC proposal to redesignHasField
, which is blocking this. -
@sheaf is fixing many bugs with DuplicateRecordFields
(!8686 (merged)).
The remainder of this ticket is historical, much of it may not be relevant once !8686 (merged) lands.
Planned code cleanup:
-
Refactor
GHC.Types.Name.Reader
(#19116 (closed)). -
Remove
AmbiguousFieldOcc
and simplify field name resolution in accordance with ghc-proposals#366 (#19461).-
Issue #19720 (closed) tracks progress on removal ofdoneAmbiguousFieldOcc
fromHsRecFld
which is being worked on by @shayne-fletcher-da - Issue #19891 (closed) tracks the need to update documentation in the Users Guide and release notes for whenever this is to get deployed
-
-
Simplify the representation of
RecordUpd
forOverloadedRecordUpdate
following !4532 (closed). See RefactorRecordUpd
syntax (#19463).-
Issue #19783 (closed) tracks progress on changing representation ofdoneHsGetField
andHsProjection
which is being worked on by @shayne-fletcher-da -
Issue #19848 (closed) tracks progress on renamingdoneHsRecField'
toHsFieldBind
and various related changes which is being worked on by @shayne-fletcher-da
-
Issues for the future:
-
Fix bugs in GHCi related to
DuplicateRecordFields
(#13438 (closed), #19314 (closed), #19322 (closed)). -
Resolve issues around representing
DuplicateRecordFields
in Template Haskell (#14848 (closed), #17381 (closed), #17551 (closed), #19664 (closed)). This primarily requires investigation of the best way to represent field names in the TH AST, ideally a way that avoids losing information when it is known which datatype contains the field. -
Continue improving dark corners of the renamer, i.e. the fact that mangled selector
Name
s are used to represent fields, so one must be very careful not to use theName
'sOccName
as if it were meaningful to users). Avoid #13352 (closed), perhaps by reducing the reliance on name-mangling? -
Warnings around partial fields (#18650 (closed)).
-
Improve
HasField
error messages (#18776). -
Improve
DuplicateRecordFields
error messages (#14892 (closed), #17420 (closed), #17469 (closed)). -
Refactor
RecordUpd
syntax (#19463)
Already done:
-
Resolve the interaction between DuplicateRecordFields
and pattern synonyms (#11228 (closed), #14630 (closed), #17176 (closed), #18452 (closed)), and simplify some dark corners of the renamer (in particular the unsatisfactory representation ofGlobalRdrElt
). Implemented by @adamgundry (!4467 (closed)). In GHC 9.2. -
NoFieldSelectors
(#5972 (closed), ghc-proposals#160). Initially implemented by @reactormonk and @fumieval (!4017 (closed)). Revised by @adamgundry (!4743 (closed)) along with extendingDisambiguateRecordFields
to cover updates (#18999 (closed)) and fixing some bugs (#18729 (closed), #19213 (closed)). In GHC 9.2. -
Add -Wambiguous-fields
(#18966 (closed), ghc-proposals#366). Implemented by @adamgundry (!4770 (closed)). In GHC 9.2. -
Record dot syntax (#18599 (closed), ghc-proposals#282). This has been split into OverloadedRecordDot
(which does not needsetField
) andOverloadedRecordUpdate
(which will requireRebindableSyntax
until we havesetField
inGHC.Records
); see ghc-proposals#405. Implemented by @shayne-fletcher-da (!4532 (closed)). In GHC 9.2.