It feels like the record builder syntax is overly willing to add line breaks when creating complex records. I would like to format the following more compactly:
builtData =
Builder.start {
childData: <-
Builder.child \child ->
Builder.start {
abc: <- Builder.data child.abc,
xyz: <- Builder.data child.xyz,
}
|> Builder.finish,
}
|> Builder.finish
Ideally, this would be allowed by the formatter:
builtData =
Builder.start {
childData: <- Builder.child \child ->
Builder.start {
abc: <- Builder.data child.abc,
xyz: <- Builder.data child.xyz,
}
|> Builder.finish,
}
|> Builder.finish
However, the formatter currently forces the first option. I think there's not a loss of readability, and it also doesn't cost as much in horizontal space. Does anyone disagree? If not, I can make a GitHub issue.
<- and -> on the same line is a bit strange...but overall, I agree. More compact is better.
I do significantly prefer the current style, for me it's effortless to see what goes in childData in the first code snippet and it's not for the second one. People disliking arrows in different directions on the same line has come up several times.
The arrows in different directions argument makes sense to me. I think it's consistent and readable, the main thing I'm feeling is a worry that consumers of these builder API's will be less wont to use them since they're more and more verbose
To solve the verbosity; In snippets where Builder occurs many times, it may be best to go with an alias like Bdr or even B. I think Builder is also highlighted with our syntax highlighting and not just on zulip? From a UX perspective, Builder also stands out a lot on every line, but it is far from the most important word in the line of code.
Yeah, I made it longer to make my pseudo-example
So long as we don't plan on having a line length limit, I don't think the current issue will lead to formatting issues with really nested builders
So it's probably fine
Sam Mohr said:
So long as we don't plan on having a line length limit
we already do have a line length limit :sweat_smile:
in the future it'll probably be ~65K bytes
(per line)
Last updated: Jun 16 2026 at 16:19 UTC