Skip to content
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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Support let blocks in nickel #736

wants to merge 1 commit into from

Conversation

jneem
Copy link
Member

@jneem jneem commented Sep 11, 2024

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

let
a = 1,
b = 2,
in
a + b

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

let
  a = 1,
  b = 2,
in
a + b

but it feels a bit strange to me to indent the bindings and not the term after "in".

Checklist

Checklist before merging:

  • CHANGELOG.md updated
  • README.md up-to-date

@yannham
Copy link
Member

yannham commented Sep 12, 2024

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:

let
  a = 1,
  b = 2,
in
  let
    c = a,
    d = b,
  in
    let ...

@nbacquey nbacquey added the language: nickel Nickel formatting issues label Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language: nickel Nickel formatting issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants