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

Enforce braces around iterator bodies #3091

Open
lukaszcz opened this issue Oct 8, 2024 · 2 comments
Open

Enforce braces around iterator bodies #3091

lukaszcz opened this issue Oct 8, 2024 · 2 comments

Comments

@lukaszcz
Copy link
Collaborator

lukaszcz commented Oct 8, 2024

Currently, the braces are optional. I think we should make them mandatory to make the syntax more consistent.

For example:

for (acc := t) (x in d) {
    deleteWith p x acc
}

Now we also allow:

for (acc := t) (x in d)
  deleteWith p x acc
@lukaszcz lukaszcz added the syntax label Oct 8, 2024
@lukaszcz lukaszcz added this to the 0.6.7 milestone Oct 8, 2024
@lukaszcz
Copy link
Collaborator Author

The formatting is also sometimes weird, e.g.,

  for (acc := empty) (x in tree1)
    {if
      | isMember x tree2 := insert x acc
      | else := acc};

It should be:

  for (acc := empty) (x in tree1) {
    if
     | isMember x tree2 := insert x acc
     | else := acc
  };

@lukaszcz
Copy link
Collaborator Author

Actually, I propose to have a separate case for single-line iterator applications without braces but enforcing the parentheses around the body:

map (x in s) (key x)

This would be formatted differently than the version with braces where newlines would be enforced:

map (x in s) {
  key x
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant