Records in Haskell

Ganesh Sittampalam ganesh at earth.li
Fri Sep 16 07:46:35 CEST 2011


On 15/09/2011 15:43, Ian Lynagh wrote:
> On Thu, Sep 15, 2011 at 08:47:30AM +0000, Simon Peyton-Jones wrote:
>>
>> Provoked the (very constructive) Yesod blog post on "Limitations of Haskell", and the follow up discussion, I've started a wiki page to collect whatever ideas we have about the name spacing issue for record fields.
>>
>>                 http://hackage.haskell.org/trac/ghc/wiki/Records
>>
>> As Simon M said on Reddit, this is something we'd like to fix; but we need a consensus on how to fix it.
> 
> Re TypeDirectedNameResolution, I would actually prefer it if it were
> less general. i.e. if you were to write
>     x.f
> then f would be required to be a record selector.
> 
> Then there's no need for the "If there is exactly one f whose type
> matches that of x" unpleasantness. Instead, the type of x must be
> inferred first (without any knowledge about the type of f), and then we
> know immediately which f is being referred to.

One benefit of TDNR is to replicate the discoverability of APIs that OO
programming has - if x :: Foo then typing "x." in an IDE gives you a
list of things you can do with a Foo. (Obviously it's not a complete lis
for various reasons, but it does allow the author of Foo and others to
design discoverable APIs.)

So I think we'd be losing quite a bit to force f to be a record selector.

Ganesh



More information about the Glasgow-haskell-users mailing list