-
Notifications
You must be signed in to change notification settings - Fork 30
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
Support let blocks in nickel #736
Conversation
I vote for the second solution, which is for example what Nix formatters do (and Dhall, I think) and also is more in-line with the way we currently format multi-line let-bindings. The rationale is that bindings are "one level deeper", but the body is the continuation of the program, and can be huge. And you often chain let-bindings a lot, so you don't want to end up with something like:
|
Ok, I went for the indented bindings. Btw, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, although there are no test cases (see topiary-cli/tests/samples/{input,expected}/nickel.ncl
)
Good call on the testing -- I've bumped into some idempotency issues, so will need to revisit this tomorrow... |
Ok, it turned out my issues were caused by the comma in a let block inside a container being misinterpreted as a comma separating two items in the container. I fixed this by changing the container comma rule to only track commas after a container element, and not at some arbitrary position in the container. |
Support let blocks in nickel
Description
Nickel's master branch now has support for "let blocks", where multiple comma-separated bindings can be placed between the "let" and the "in", like
This PR introduces support for formatting let blocks, which it handles differently from single let bindings in two ways: the first binding is allowed to go on its own line, and new lines are allowed after each comma.
It would also be possible to indent the bindings, like
but it feels a bit strange to me to indent the bindings and not the term after "in".
Checklist
Checklist before merging: