The 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. It consists of three separate of components, of which two will be in GHC 8.0. For more information, see:

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).


Open Tickets:

Implement TDNR
Interaction between ORF and record pattern synonyms needs to be resolved.
Unable to infer type when using DuplicateRecordFields
Allow applying type to label
Allow labels starting with uppercase with OverloadedLabels
RebindableSyntax and OverloadedLabels
UnboxedTuple makes overloaded labels fail to parse

Closed Tickets:

DuplicateRecordFields + TemplateHaskell
Fixity of field-deconstructors incorrect
Infix declarations for record fields with DuplicateRecordFields are broken
Interaction between ORF and record pattern synonyms needs to be resolved.
Auto complete in ghci shows $sel:function:Type for DuplicateRecordFields fields
Regression using NamedFieldPuns with qualified field names
DuplicateRecordFields appears not to work in GHCi

Add ORF to the ticket's keywords to include it in these lists.



The extension was implemented in 2013 as a Google Summer of Code project, by Adam Gundry under the mentorship of Simon Peyton Jones.

Last modified 8 months ago Last modified on Jan 5, 2016 12:03:42 PM