Smart linebreak printer for pipe chains
They are currently being formatted based on line width. it would be good to allow user decide whether to break line on pipes or not.
for example this code gets formatted to a single line with default line width
let bazz = foo.bars->OptionEx.arrayValues->Map.String.fromArray
I found this more readable
let bazz =
foo.bars
->OptionEx.arrayValue
->Map.String.fromArray
Yes, that’s something I’ve also been thinking about. As the line width gets longer, the width algorithm becomes less and less “nice”. There’s definitely an opportunity for improvement here.
There's a balance to be had, because for some pipes (e.g. if the above used local functions and was foo.bars->arrayValues->fromArray I'd rather it stay on one line. Perhaps trigger wrap based on the number of pipes (e.g. 3) rather than line width?
The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions.