Skip to content

feat: add Qq wrappers for ToExpr#5952

Open
eric-wieser wants to merge 17 commits intomasterfrom
eric-wieser/toExprQ
Open

feat: add Qq wrappers for ToExpr#5952
eric-wieser wants to merge 17 commits intomasterfrom
eric-wieser/toExprQ

Conversation

@eric-wieser
Copy link
Copy Markdown
Member

@eric-wieser eric-wieser commented Jul 16, 2023

@eric-wieser eric-wieser added awaiting-review awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. labels Jul 16, 2023
@eric-wieser eric-wieser requested a review from gebner July 16, 2023 23:25
Comment on lines +42 to +47
/-- `Lean.toExpr` with Qq support. -/
def Lean.ToExpr.mkQ.{u} {α : Type u} [Lean.ToLevel.{u}]
(toTypeExprQ : Q(Type $(Lean.toLevel.{u}))) (toExprQ : α → Q($toTypeExprQ)) :
ToExpr α where
toTypeExpr := toTypeExprQ
toExpr x := toExprQ x
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This definition seems to get confused with universe variables if I actually try to use it.

instance toExpr (n : ℕ) : Lean.ToExpr (Fin n) where
toTypeExpr := q(Fin $n)
toExpr := match n with
instance toExpr (n : ℕ) : Lean.ToExpr (Fin n) := Lean.ToExpr.mkQ.{0}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Without the {0} this gives

type mismatch
  Fin «$n»
has type
  Type : Type 1
but is expected to have type
  Type 127 : Type 128

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, this is the ToLevel issue I've alluded to on Zulip. Depending on the order the instances are synthesized, we can end up searching for an instance of ToLevel.{?u}. And since the succ instances has higher priority than the zero instance, we get ToLevel.{127} as a result. If we'd swap the instance priorities, we'd get ToLevel.{0}. Of course, neither choice is desirable.

@github-actions github-actions bot removed the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Jul 17, 2023
@eric-wieser eric-wieser added the t-meta Tactics, attributes or user commands label Aug 2, 2023
@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 15, 2023
@ghost ghost removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 18, 2023
@eric-wieser eric-wieser added the awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. label Aug 18, 2023
@ghost ghost added the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Aug 21, 2023
@ghost ghost removed the blocked-by-other-PR This PR depends on another PR (this label is automatically managed by a bot) label Aug 21, 2023
@ghost
Copy link
Copy Markdown

ghost commented Aug 21, 2023

This PR/issue depends on:

@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 21, 2023
@ghost ghost removed the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Aug 23, 2023
@bors bors bot changed the base branch from master to ScottCarnahan/BinomialRing2 September 17, 2023 03:24
@kim-em kim-em changed the base branch from ScottCarnahan/BinomialRing2 to master September 17, 2023 12:16
@ghost ghost added the merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) label Sep 18, 2023
@ghost ghost added merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) and removed merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) labels Apr 17, 2024
@grunweg
Copy link
Copy Markdown
Contributor

grunweg commented Apr 15, 2025

Coming here from triaging old PRs: is this PR still relevant? (I vaguely remember some material around ToExpr being upstreamed to core - that might have been something else, though.)

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

Labels

awaiting-CI This PR does not pass CI yet. This label is automatically removed once it does. merge-conflict The PR has a merge conflict with master, and needs manual merging. (this label is managed by a bot) t-meta Tactics, attributes or user commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants