GHC support for the new "record" package

Adam Gundry adam at well-typed.com
Wed Jan 21 21:34:05 UTC 2015


On 21/01/15 18:14, Edward Kmett wrote:
>     >> 5) I don't know if I want to commit the *language* to a particular lens
>     >> type.
> 
>     Agreed, but I don't think this need be an issue for either proposal. We
>     know from ORF that we can make fields sufficiently polymorphic to be
>     treated as selector functions or arbitrary types of lenses (though
>     treating them as van Laarhoven lenses requires either some clever
>     typeclass trickery in the base library, or using a combinator to make a
>     field into a lens at use sites).
> 
> 
> Admittedly that has also been the source of 90% of the complexity of the
> ORF proposal. There we _had_ to do this in order to support the use as a
> regular function.

I'm surprised and interested that you view this as a major source of
complexity. From my point of view, I quite liked how the ability to
overload fields as both selector functions and arbitrary lenses turned
out. Compared to some of the hairy GHC internal details relating to name
resolution, it feels really quite straightforward. Also, I've recently
worked out how to simplify and generalise it somewhat (see [1] and [2]
if you're curious).


> There is a large design space here, and the main thing Nikita's proposal
> brings to the table is slightly different assumptions about what such
> records should mean. This _could_ let us shed some of the rougher edges
> of ORF, at the price of having to lock in a notion of lenses.

Yes. It's good to explore the options. For what it's worth, I'm
sceptical about blessing a particular notion of lenses unless it's
really necessary, but I'm prepared to be convinced otherwise.


> I'm on the fence about whether it would be a good idea to burden
> Nikita's proposal in the same fashion, but I think it'd be wise to
> explore it in both fashions. My gut feeling though is that if we tie it
> up with the same restrictions as ORF you just mostly get a less useful
> ORF with anonymous record sugar thrown in.

I think there's a sensible story to tell about an incremental plan that
starts with something like ORF and ends up with something like Nikita's
anonymous records. I'll try to tell this story when I can rub a few more
braincells together...

Adam

[1]
https://github.com/adamgundry/records-prototype/blob/master/NewPrototype.hs
[2]
https://github.com/adamgundry/records-prototype/blob/master/CoherentPrototype.hs

-- 
Adam Gundry, Haskell Consultant
Well-Typed LLP, http://www.well-typed.com/


More information about the ghc-devs mailing list