You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Topiary's default OCaml formatting is very aerated (especially in multi-line mode), which I enjoy quite a lot. However, sometimes, I find it too aerated and I wished some things stayed on the same line. This is for instance the case with lists, arrays, records, and maybe tuples. I feel we could often opt for a slightly more compact style by making them dangle at the end of the previous line. I think this is also a common OCaml style.
Describe the solution you'd like
Record types are actually already kept dangling by Topiary:
typefoo = {
x : int;y : float;
}
but not records are almost never dangling in other situations:
My input
Topiary's output
let foo = {
x =2;
y =12.;
}
let foo =
{
x =2;
y =12.;
}
let()=let foo = {
x =2;
y =12.;
}
in
something_with_foo
let()=let foo =
{
x =2;
y =12.;
}
in
something_with_foo
let()=
my_function {
x =2;
y =12.;
}
let()=
my_function
{
x =2;
y =12.;
}
let()=
my_function @@ {
x =2;
y =12.;
}
let()=
my_function @@
{
x =2;
y =12.;
}
I don't know about dangling in function applications, because I feel this might only make sense for the last argument of that application. However, I do feel it might make sense in a let or after an operator such as @@.
Lists and arrays would deserve a similar treatment, at least for consistency (and they don't occur in types). And maybe we should also apply the same logic to multi-line tuples, but somehow I'm less certain about this one.
Describe alternatives you've considered
Frankly, the current style is quite good. Maybe we should at least make it more consistent (record types are dangling but nothing else) but apart from that I'm not entirely sure we need those changes. I at least wanted to start a discussion on this.
Additional context
Related to #660 which covers dangling fun . -> and to #657 for the treatment of operators. @aspiwack I imagine you might have an opinion on this.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Topiary's default OCaml formatting is very aerated (especially in multi-line mode), which I enjoy quite a lot. However, sometimes, I find it too aerated and I wished some things stayed on the same line. This is for instance the case with lists, arrays, records, and maybe tuples. I feel we could often opt for a slightly more compact style by making them dangle at the end of the previous line. I think this is also a common OCaml style.
Describe the solution you'd like
Record types are actually already kept dangling by Topiary:
but not records are almost never dangling in other situations:
I don't know about dangling in function applications, because I feel this might only make sense for the last argument of that application. However, I do feel it might make sense in a
let
or after an operator such as@@
.Lists and arrays would deserve a similar treatment, at least for consistency (and they don't occur in types). And maybe we should also apply the same logic to multi-line tuples, but somehow I'm less certain about this one.
Describe alternatives you've considered
Frankly, the current style is quite good. Maybe we should at least make it more consistent (record types are dangling but nothing else) but apart from that I'm not entirely sure we need those changes. I at least wanted to start a discussion on this.
Additional context
Related to #660 which covers dangling
fun . ->
and to #657 for the treatment of operators. @aspiwack I imagine you might have an opinion on this.The text was updated successfully, but these errors were encountered: