A possible alternative to dot notation for record access

AntC anthony_clayden at clear.net.nz
Mon Jul 1 04:59:44 CEST 2013


> 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). ...




More information about the Glasgow-haskell-users mailing list