Status update on overloaded records work?

AntC anthony_clayden at
Wed Oct 16 09:12:58 UTC 2013

> Simon Peyton-Jones <simonpj at ...> writes:
> | - (What I was hoping for but didn't get.)
> |   No compiler flag to suppress creating selector functions.
> |   This would have allowed records to be declared re-using the same
> | name;
> |   but left it entirely to the developer as to how to access them.
> |   (I was trying to promote the TH and/or Lenses cottage industries.)
> This is an petty orthogonal design request, which is why it wasn't part 
of Adam's project.

The fishhooks are likely to be with naming and scoping (as you point out);
and that was part of what Adam worked on.

> However I could imagine some pretty puzzled users.
> ("I imported module M, which defines a type T with field f,
> but GHC says 'f is not in scope'". 
> Turns out that M was compiled (via a command-line option) with
> -XNoRecordSelectors.) 

The developer of module M is only going to switch on this option
if they're wanting to re-use field names.
So without the option, M wouldn't even compile.
And they're going to provide some other way to access the fields.
Very possibly a Lens.
Very possibly a (overloaded) selector function f.

Now perhaps there is some reason it won't work,
or isn't ergonomic.
But at the moment there's no way to even try.
The Lens library has all sorts of TH work-rounds:
* declare field labels with prefixes.
* make sure the prefix is exactly the typename, with underscore.
* strip those off with TH to create an overloaded selector function f.

> I don't really buy it, but I don't massively object either, if someone 
wants to offer a patch.

Yes, that would be great! The write-up is at


More information about the ghc-devs mailing list