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

Avoid simpleBinder nesting #1296

Merged
merged 2 commits into from
Jul 8, 2022
Merged

Avoid simpleBinder nesting #1296

merged 2 commits into from
Jul 8, 2022

Conversation

Kha
Copy link
Member

@Kha Kha commented Jul 8, 2022

@Kha Kha requested a review from leodemoura July 8, 2022 13:39
@Kha
Copy link
Member Author

Kha commented Jul 8, 2022

The code changes suggest that it would be nice to have Term.binderIdent be a proper syntax kind, in which case it could be unified with Lean.binderIdent from Init.Tactics, which I might do in a follow-up PR.

@gebner
Copy link
Member

gebner commented Jul 8, 2022

The code changes suggest that it would be nice to have Term.binderIdent be a proper syntax kind, in which case it could be unified with Lean.binderIdent from Init.Tactics, which I might do in a follow-up PR.

Yes, that's a very good idea. Please also unify it with ident <|> "_" when you're at it. See also: leanprover-community/mathport#152 (comment)

| ``Lean.Parser.Term.strictImplicitBinder
| ``Lean.Parser.Term.instBinder
| ``Lean.Parser.Term.explicitBinder
| ``Lean.Parser.Term.hole | `ident => loop body (i+1) (newBinders.push binder)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. It is great to see new features making our code cleaner :)

@@ -552,7 +558,7 @@ def expandMatchAltsWhereDecls (matchAltsWhereDecls : Syntax) : MacroM Syntax :=

open Lean.Elab.Term.Quotation in
@[builtinQuotPrecheck Lean.Parser.Term.fun] def precheckFun : Precheck
| `(fun $binders* => $body) => do
| `(fun $binders* $[: $ty?]? => $body) => do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use _ty to avoid the warning from the unused variable linter?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, not sure why I didn't see the warning. Will fix when I'm home.

views[0]!.binders.getArgs.all (·.getKind == ``Parser.Term.simpleBinder) then
some <| (views[0]!.binders.getArgs.toList.map (fun stx => stx[0].getArgs.toList.map (·.getId))).join
views[0]!.binders.getArgs.all (·.isIdent) then
some (views[0]!.binders.getArgs.toList.map (·.getId))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@leodemoura
Copy link
Member

The code changes suggest that it would be nice to have Term.binderIdent be a proper syntax kind, in which case it could be unified with Lean.binderIdent from Init.Tactics, which I might do in a follow-up PR.

Yes, that's a very good idea. Please also unify it with ident <|> "_" when you're at it. See also: leanprover-community/mathport#152 (comment)

I think this is a good idea, but we can use another PR for this unification.
The current one is already a good improvement.

@leodemoura
Copy link
Member

@Kha The failure has nothing to do with this PR. Please feel free to merge it as-is.

@Kha Kha merged commit 7ee5203 into leanprover:master Jul 8, 2022
@Kha Kha deleted the no-simpleBinder branch July 8, 2022 17:06
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.

3 participants