A possible alternative to dot notation for record access

Edward Kmett ekmett at gmail.com
Mon Jul 1 07:12:47 CEST 2013


If you really want to hunt for unused syntax and we wind up needing a (.)
analogue then (->) is currently a reserved operator, so opening it up for
use at the term level could be made to work, and there is a precedent with
c/c++ pointer dereferencing.

-Edward

On Mon, Jul 1, 2013 at 1:10 AM, Edward Kmett <ekmett at gmail.com> wrote:

> (#) is a legal operator today and is used in a number of libraries.
>
>
> On Sun, Jun 30, 2013 at 11:38 PM, <amindfv at gmail.com> wrote:
>
>> 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
>>
>> _______________________________________________
>> 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/20130701/cd7f14d1/attachment-0001.htm>


More information about the Glasgow-haskell-users mailing list