@art, I disagree about adding arbitrary expressions between { and |. You 
should use a let-binding for something like *Array.get (offset + i) 
arrayOfRecords |> Maybe.withDefault defaultRecord*.

I know this is supposed to be pain points, not solutions, I'm going to try 
to coalesce some of the syntax proposals that have been brought up.

*Qualified names as base records*, such as {Module.defaultOptions | ... }. 
The default options pattern makes this very useful and it does not 
encourage nesting records deeply.

*Dot-accessed records as base records*. This would allow { element.padding 
| left = "4px" }. Having records as fields of other records is especially 
useful when the subrecord type can be reused (e.g. { padding : Rect, margin 
: Rect }.

*Arbitrary expressions as base records*. Allow anything of record type. I 
disagree with this one per above.

---------

*Nested getter functions*, so that *.foo.bar* is sugar for *.foo >> .bar*

*Setter functions*, perhaps with syntax *.foo=*

*Nested setter functions*, a combination of the two above, *.foo.bar=*

*Setters that take a function given the current value of the field as an 
argument.* *padding |> .right@ (\padRight -> padRight * 2)* This is 
particularly useful for mapping over lists instead of setting one value.

*-----*

I wonder if we could dispense with the vertical bar update syntax entirely 
if we had nested setters. Something like

Style.defaults
  |> .padding.left = 5
  |> .margin.top = 10

The compiler should specifically optimize this case so that many chained 
updates do not create intermediate records. (A downside is that you lose 
the ability to refer to the current record in the expression for the new 
value, but that record wouldn't exist because of the optimization. So that 
would mean you can't easily map over a list that's in a record.)

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to