OverloadedRecordFields extension for GHC will allow multiple record datatypes to share the same field names, and make it possible for type information to disambiguate them. For more information, see:
GHC proposal for OverloadedRecordFields (2016 - most up to date)
Original design (2013)
Content previously on this page has been moved to the SORF page.
Lennart: I've implemented 2&3 in the Mu compiler, and I'll add some comments about it.
Lennart: The MagicClasses proposal is fundamentally broken, because it breaks abstraction.
If we have a data type
R with a field
foo of type
T, then we generate
instance HasField "foo" R T.
Since instances are silently exported and imported it means that this instance is now available in every module that somehow depends on the defining module. This means that the
foo field of
R is now accessible everywhere. There is no way to limit the scope of
foo anymore. This is really terrible. Any record proposal that no longer allows abstract data types to be defined is broken.
Adam: I don't think so. We will only solve a
HasField constraint automatically in modules that have the field in scope, and thus we can retain the same abstraction rules as normal Haskell. This is just like
Coercible. We don't really generate and export instances, rather there is special behaviour in the constraint solver. See discussion on representation hiding (now updated to the latest design).
|#11228||Interaction between ORF and record pattern synonyms needs to be resolved.|
|#11343||Unable to infer type when using DuplicateRecordFields|
|#11352||Allow applying type to label|
|#11671||Allow labels starting with uppercase with OverloadedLabels|
|#13352||Strange requirement for re-exported duplicate record fields|
|#13438||ghci :browse does not work with DuplicateRecordFields|
|#14848||-XDuplicateRecordFields breaks record expression splices|
|#14892||Field imposters with DuplicateRecordFields and NamedFieldPuns.|
|#15277||Move field name resolution to the type-checker|
|#16232||Add setField to HasField|
|#11103||DuplicateRecordFields + TemplateHaskell|
|#11167||Fixity of field-deconstructors incorrect|
|#11173||Infix declarations for record fields with DuplicateRecordFields are broken|
|#11227||Interaction between ORF and record pattern synonyms needs to be resolved.|
|#11328||Auto complete in ghci shows $sel:function:Type for DuplicateRecordFields fields|
|#11662||Regression using NamedFieldPuns with qualified field names|
|#12097||DuplicateRecordFields appears not to work in GHCi|
|#12243||RebindableSyntax and OverloadedLabels|
|#12459||UnboxedTuple makes overloaded labels fail to parse|
|#12609||unused-top-binds wrongly warns about underscore-prefixed field names when DuplicateRecordFields enabled|
|#13132||Compilation fails with a panic: get_op runContT|
|#13847||record construction accepts local unqualified name instead of qualified imported name|
|#13947||GHC 8.2 gives misleading error message for out-of-scope infix type constructor|
|#14487||Can't Hide Field When DuplicateRecordFields Is Enabled|
|#14783||Initializing record with similarly named field from a different record results in warning rather than error|
|#14953||Panic when exporting duplicate record fields from separate modules|
|#15149||Identical distinct type family fields miscompiled|
Add ORF to the ticket's keywords to include it in these lists.
Phab:D761, Phab:D1391, Phab:D1486, Phab:D1586, Phab:D1600:
- Phab:D1687: magic classes
- Prototype implementation of the magic typeclasses
The extension was implemented in 2013 as a Google Summer of Code project, by Adam Gundry under the mentorship of Simon Peyton Jones.