Overloaded record fields

Ryan Newton rrnewton at gmail.com
Tue Jul 2 23:33:44 CEST 2013


+1 for orthogonal -XDotPostfixApply.

I'm in the absolutely-love-using-dot-for-records camp, but I also like "foo
s1.toUpper s2.toUpper".

We're already so lazy about parentheses -- e.g. the non-haskellers I show
code to are always appalled at $ ;-) -- and this helps scrap more parens!



On Mon, Jul 1, 2013 at 8:53 AM, Adam Gundry <adam.gundry at strath.ac.uk>wrote:

> Hi all,
>
> I have amended the plan [1] as a result of the ongoing discussion,
> including leaving the syntax alone for the time being, so record
> projections are written prefix.
>
> Regarding Barney's suggestion of field declarations:
>
> On 01/07/13 10:50, Barney Hilken wrote:
> > All this extra syntax, whether it's ., #, or {} seems very heavy for a
> problem described as very rare.
> > Why not simply use a declaration
> >
> >       field name
> >
> > whose effect is to declare
> >
> >       name :: r {name ::t} => r -> t
> >       name = getFld
> >
> > unless name is already in scope as a field name, in which case the
> declaration does nothing?
>
> This makes sense. I guess the question is whether a new declaration form
> is justified. The implementation is slightly more subtle than you
> suggest, because we don't know whether `name` will be brought into scope
> as a field later, in which case the definition would clash with the
> actual field. It should be equivalent to defining
>
> data Unused { name :: () }
> data Unused2 { name :: () }
>
> (twice so that there is always ambiguity about a use of `name`).
>
> Adam
>
> [1]
>
> http://hackage.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/Plan
>
>
>
> _______________________________________________
> 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/20130702/702fe59c/attachment.htm>


More information about the Glasgow-haskell-users mailing list