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

feat: allow doSeq in let x <- e | seq #1809

Merged
merged 1 commit into from
Nov 8, 2022

Conversation

digama0
Copy link
Collaborator

@digama0 digama0 commented Nov 7, 2022

By changing let x <- e | seq to allow a sequence of doElems at seq instead of just one, it fixes #1804. The syntax extension is also convenient in some cases.

tests/lean/1804.lean Outdated Show resolved Hide resolved
@Kha
Copy link
Member

Kha commented Nov 7, 2022

Nice generalization. I assume it's not trivial to trigger a sequence unintentionally unless you do something like

let x <- a | b
             c

? Seem fine to me then.

@Kha Kha added the changelog label Nov 7, 2022
@digama0
Copy link
Collaborator Author

digama0 commented Nov 7, 2022

I would use the formatting

let x <- a
  | b
    c

if I actually wanted a sequence, which I think looks clear enough. (You can also hang the | on the previous line if you want to use only one indent level - this is the style formatTerm uses. It is not allowed to use no indent for the | though.) We should probably be using colEq for the do parser though, since currently the above parses as if it was

let x <- a
  | b
c

which seems very misleading.

@Kha
Copy link
Member

Kha commented Nov 7, 2022

Yes, colEq would be appropriate

@gebner
Copy link
Member

gebner commented Nov 7, 2022

Ideally, do would use sepByIndent like by etc. (which uses colEq internally). The reason I didn't do that myself is because I didn't want to touch the do notation expander, but you could give it a try.

@leodemoura leodemoura merged commit 4bf89df into leanprover:master Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Counter intuitive behavior at do notation
4 participants