-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refmt long chain of simple |> doesn't break at all #1066
Comments
I would like it to see it formatted as: let x =
foo
|> f
|> g
|> x; |
I like that breaking too. It might be easier to just do this for all infix, if it looks okay. |
@jordwalke What would that mean for |
@hcarty There are two issues right now with |
@jordwalke I see, I read the suggestion as 'break at every |
I'm taking a look atm |
@IwanKaramazow depending on how deep you get into it #1045 also seems related. |
@IwanKaramazow What did you find with this formatting challenge? Bob's example of formatting would be great for all infix identifiers:
Did you see a specific challenge that I can help with? |
@IwanKaramazow thanks for taking a look! Do you have any updates, this is my single biggest issue with refmt at the moment. This was my attempt at a fix in #1045 but couldn't quite get it right: https://github.com/facebook/reason/compare/master...kyldvs:pipe-chaining?expand=1 |
The challenge is mainly in generalizing to all infix operators.
In the first we don't want breaking, while in the last we want breaking. If we would always break, this is basically a one-liner though 😄 |
Happy to help. I do know that part of the code fairly well, and I know it's complicated because of the fact that we need to recover the parsing precedence table at print time to ensure that we print faithfully. |
#1259 contains a PR which unblocks the @jordwalke can you take a look, does it make sense what I'm doing? |
Regarding: What I discovered is that the problem of printing the absolute minimum number of parens requires that deep parts of the AST know about the higher parts of the AST that they are embedded within - nonlocal knowledge. I haven't thought about it in a while but I believed that having Menhir generate some of the printing scaffolding would help. For now, what we have is decent except in a couple of cases where we print too many parens. |
Fixed by #1259 |
formatTest/customMLFiles/kad.re
:_build/src/refmt_impl.native formatTest/customMLFiles/kad.re --print-width 80
results in on master:The text was updated successfully, but these errors were encountered: