A possible alternative to dot notation for record access

Carter Schonwald carter.schonwald at gmail.com
Sun Jun 30 09:26:22 CEST 2013


indeed, this relates / augments record puns syntax already in GHC
http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#record-puns
.

Otoh, would there be any ambiguity wrt applying functions to blocks?


eg
f = (+ 1)
h= f {let x = 7 in 3*x},
would that trip up the syntax?




On Sun, Jun 30, 2013 at 2:59 AM, Judah Jacobson <judah.jacobson at gmail.com>wrote:

> Hi all,
>
> I had a quick idea about record field syntax as specified in the GSoC
> project plan:
> http://hackage.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/Plan
> .
>
> Instead of "f.x" (to access field x of record f), maybe we could write
> "f{x}" as the record selection.  That is, we'd reuse the brace notation
> which is already in place for record updates.  Unlike dot notation, this is
> unambiguous and doesn't conflict with any existing syntax (AFAIK).  It
> would also generalize to "f{x}{y}{z}" instead of "f.x.y.z".
>
> This proposal would add two new forms of expressions:
>
> f{x} to access field x of data f
> ({x}) = \f -> f{x} as a field access section
>
> Additionally, it seems like record mutation expressions could also have
> sections:
>
> ({x=2}) = \f -> f{x=2}
>
> That actually seems useful by itself, regardless of whether we use dot
> notation for field access.
>
> Best,
> -Judah
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20130630/59fcf9fa/attachment-0001.htm>


More information about the Glasgow-haskell-users mailing list