so in Elm, elm-format formats lists like this:
[ a, b, c ]
I wrote the original design doc for elm-format, and my reasoning for this design was to be consistent with the vertical style, which was this:
[ a
, b
, c
]
so the idea was that there would consistently be a space between the opening brace and the first element, regardless of whether it was written vertically or horizontally
in Roc, our vertical format looks like this:
list = [
a,
b,
c,
]
so we could do the horizontal style either way:
[ a, b, c ]
[a, b, c]
in a couple of weeks I'm gonna give a fairly extended demo of examples/gui, so I figured I'd bring this up now before then in case it makes sense to change
one of the implications of this would be that it would impact type annotations as well, so for example the type of List.get would change:
get : List elem, Nat -> Result elem [ OutOfBounds ]*
get : List elem, Nat -> Result elem [OutOfBounds]*
I don't have a strong preference either way on [ a, b, c ] vs [a, b, c] but I do like the error type being more compact in get
of note, I think it's important to be consistent on these - so if lists are compact, records should be too - e.g. {x, y, z} over { x, y, z } - as should imports and such in module headers
curious what others think!
I am partial to adding the space. Just find that I have been adding it to my code (tags and lists) cause it makes things slightly more readable to me, but no major opinion.
I find I want it most with tags that have type variables: [Err a] just reads weird to me without the spaces
Or worse: [T a b] or [T (Dict k v) b]
is that only if it's a single tag?
e.g. how do you feel about these?
Bool : [ True, False ]
Result ok err : [ Ok ok, Err err ]
Bool : [True, False]
Result ok err : [Ok ok, Err err]
I still likely it slightly better with the space. I guess it also depends a lot of the syntax coloring though.
By making the brackets hide more with coloring, space or not matters even less.
Maybe this means the brackets in my color scheme are too bold so I want the space.
would this affect parenthesis as well? someFunc (someOtherFunc "hello") vs someFunc ( someOtherFunc "hello" ). If not then maybe that could be an argument for no spaces for [] or {} as well
Not having a space would simplify things for the editor because I wouldn't need to add or remove spaces for multi-line vs single-line vs empty lists/records. Although in design in general, having more spacing between elements is nicer to look at.
I'm confident people will get used to it either way, just as you see people get used to reading code when you take away token-based syntax highlighting in favor of a more useful contextual colorization.
If we add more spacing we should also (I believe) encourage formatting styles that keep elements together: perhaps give your error union a name instead of wrapping it over multiple lines, or have a consistent roc-format convention for a multi line annotation when it doesn't fit within however many characters on a single line
Jared Cone said:
would this affect parenthesis as well?
someFunc (someOtherFunc "hello")vssomeFunc ( someOtherFunc "hello" ). If not then maybe that could be an argument for no spaces for[]or{}as well
personally I don't think parens should have spaces regardless. (They don't currently.)
Agreed. Then that could be a minor argument for not using spaces for the other brackets. I'm in the same boat as everyone else where I don't really care, just trying to think of some logic for one way or the other :)
seems like this is a minor enough consideration either way that it's not worth changing anything; I'll plan to do the demo with the current formatting! :thumbs_up:
Last updated: Jun 16 2026 at 16:19 UTC