@Ayaz Hafiz suggested in another thread that we have a parallel of the .foo "field getter" syntax in a "field setter" syntax - so basically:
.name desugars to \record -> record.name (this already works today)&name: blah desugars to \record -> { record & name: blah } (idea #1)&name desugars to \record -> { record & name: name } (idea #2)thoughts on those ideas?
could also do something like:
&name desugars to \record, value -> { record & name: value } (idea #3)I do like that something like &name: blah is shorter but I don't like how it means there's two ways to do record updates.
Can multiple &name: blah be chained together? Something like this
record
|> &name: blah
|> &age: 6
|> &bar: "foo"
If yes, maybe the { record & name: blah } syntax could be dropped and then there would be single concise way to do record updates.
That said, maybe this format makes it harder to give good error messages?
Edit: I guess in the case of updating many fields, the chained syntax is more verbose. So that's another downside.
I'm curious what examples are of where you would benefit from that sugar? (Can't find the original mention of this idea.)
idea #3 would make a big difference in a draft API I'm working through, so I'm curious what people think of the idea in general :big_smile:
Richard Feldman said:
idea #3 would make a big difference in a draft API I'm working through, so I'm curious what people think of the idea in general :big_smile:
Oh, like it would simplify the code? I agree with @Johannes Maas, I'd love to see an example of cleaner code via setter sugar.
I'll share the API design when it's more fully baked (still working through it), but in the meantime, curious to hear opinions about use cases others have in mind!
hm I like the user experience of idea 1 and 2 syntax wise but I'm not sure I have a strong opinion on what it should desugar to
would be cool to be able to do 1 and 2 depending on the situation
Last updated: Jun 16 2026 at 16:19 UTC