A possible alternative to dot notation for record access
amindfv at gmail.com
amindfv at gmail.com
Mon Jul 1 05:38:17 CEST 2013
As long as we're bikeshedding...
Possibly '#' is unused syntax -- Erlang uses it for its records too, so we wouldn't be pulling it out of thin air. E.g. "person#firstName"
Tom
El Jun 30, 2013, a las 22:59, AntC <anthony_clayden at clear.net.nz> escribió:
>> Carter Schonwald <carter.schonwald <at> gmail.com> writes:
>>
>> 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.
>
> Uh-oh. That documentation gives an example, and it exactly explains the
> weird type-level error I got when I tried to use the proposed syntax
> myself:
>
> Note that:
>
> * Record punning can also be used in an expression, writing, for
> example,
>
> let a = 1 in C {a} -- !!!
>
> instead of
>
> let a = 1 in C {a = a}
>
> The expansion is purely syntactic, so the expanded right-hand side
> expression refers to the nearest enclosing variable that is spelled the
> same as the field name.
>
> IOW the proposal _does_ conflict with existing syntax. (And I guess I can
> see a use for the example. Note that outside of that let binding, `a`
> would be a field selector function generated from the data decl in which
> field `a` appears -- that's the weirdity I got.)
>
> I suppose the existing syntax has a data constructor in front of the
> braces, whereas the proposal wants a term. But of course a data
> constructor is a term.
>
> So the proposal would be a breaking change. Rats! Is anybody using that
> feature?
>
>>
>> On Sun, Jun 30, 2013 at 2:59 AM, Judah Jacobson <judah.jacobson <at>
> gmail.com> wrote:
>>
>> Unlike dot notation, this is unambiguous and doesn't conflict with any
> existing syntax (AFAIK). ...
>
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
More information about the Glasgow-haskell-users
mailing list