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 is working on a GHC proposal to redesignHasField
, which is blocking this.
Planned code cleanup:
-
Refactor
GHC.Types.Name.Reader
(#19116). -
Remove
AmbiguousFieldOcc
and simplify field name resolution in accordance with ghc-proposals#366 (#19461).- Issue #19720 tracks progress on removal of
AmbiguousFieldOcc
fromHsRecFld
which is being worked on by @shayne-fletcher-da
- Issue #19720 tracks progress on removal of
-
Simplify the representation of
RecordUpd
forOverloadedRecordUpdate
following !4532 (closed). See RefactorRecordUpd
syntax (#19463).
Issues for the future:
-
Fix bugs in GHCi related to
DuplicateRecordFields
(#13438, #19314 (closed), #19322 (closed)). -
Resolve issues around representing
DuplicateRecordFields
in Template Haskell (#14848, #17381, #17551, #19664). 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, perhaps by reducing the reliance on name-mangling? -
Warnings around partial fields (#18650).
-
Improve
HasField
error messages (#18776). -
Improve
DuplicateRecordFields
error messages (#14892, #17420, #17469). -
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.