-
Notifications
You must be signed in to change notification settings - Fork 380
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
[Merged by Bors] - feat: add an eval%
elaborator for interpolating the output of #eval
#10742
Conversation
test/eval_elab.lean
Outdated
/-- `Finset α` can be converted to an expr only if there is some way to find `DeciableEq α`. -/ | ||
unsafe nonrec instance Finset.toExpr | ||
{α : Type u} [ToLevel.{u}] [ToExpr α] [HasInstance (DecidableEq α)] : ToExpr (Finset α) := | ||
have u' : Level := ToLevel.toLevel.{u} | ||
have α' : Q(Type u') := Lean.ToExpr.toTypeExpr α | ||
letI : Q(DecidableEq $α') := HasInstance.expr (DecidableEq α) | ||
{ toTypeExpr := q(Finset $α') | ||
toExpr := fun x => show Q(Finset $α') from | ||
match show List Q($α') from x.val.unquot.reverse.map toExpr with | ||
| [] => q(∅) | ||
| x0 :: xs => List.foldl (fun s x => q(insert $x $s)) q({$x0}) xs } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a lot cleaner with #5952, but that PR is not ready to merge yet, and this is just a test file anyway.
Co-authored-by: damiano <[email protected]>
Co-authored-by: damiano <[email protected]>
Is this expected to work with let-bound vars? e.g. example : True := let a := 2; let b := eval% a * 2 At the moment we get some horrible fvar error: |
That's not expected to work; though it could certainly give a better message. You could always put the |
✌️ eric-wieser can now approve this pull request. To approve and merge a pull request, simply reply with |
For a future version, it would be nice if it could capture local One way to implement this: figure out which variables would need to be reverted, throw an error if any of them are not |
Co-authored-by: Kyle Miller <[email protected]>
bors merge Perhaps worth noting that this won't handle universe variables correctly until leanprover/lean4#3090 lands. |
…l` (#10742) This is taken from [my zulip message here](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/How.20to.20simplify.20this.20proof.20without.20using.20a.20have.20statement.3F/near/422294189). As an example: ```lean example : 2^10 = eval% 2^10 := by -- goal is `2^10 = 1024` sorry ```
Build failed:
|
bors merge |
…l` (#10742) This is taken from [my zulip message here](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/How.20to.20simplify.20this.20proof.20without.20using.20a.20have.20statement.3F/near/422294189). As an example: ```lean example : 2^10 = eval% 2^10 := by -- goal is `2^10 = 1024` sorry ```
Pull request successfully merged into master. Build succeeded: |
eval%
elaborator for interpolating the output of #eval
eval%
elaborator for interpolating the output of #eval
…l` (#10742) This is taken from [my zulip message here](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/How.20to.20simplify.20this.20proof.20without.20using.20a.20have.20statement.3F/near/422294189). As an example: ```lean example : 2^10 = eval% 2^10 := by -- goal is `2^10 = 1024` sorry ```
…l` (#10742) This is taken from [my zulip message here](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/How.20to.20simplify.20this.20proof.20without.20using.20a.20have.20statement.3F/near/422294189). As an example: ```lean example : 2^10 = eval% 2^10 := by -- goal is `2^10 = 1024` sorry ```
…l` (#10742) This is taken from [my zulip message here](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/How.20to.20simplify.20this.20proof.20without.20using.20a.20have.20statement.3F/near/422294189). As an example: ```lean example : 2^10 = eval% 2^10 := by -- goal is `2^10 = 1024` sorry ```
…l` (#10742) This is taken from [my zulip message here](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/How.20to.20simplify.20this.20proof.20without.20using.20a.20have.20statement.3F/near/422294189). As an example: ```lean example : 2^10 = eval% 2^10 := by -- goal is `2^10 = 1024` sorry ```
…l` (#10742) This is taken from [my zulip message here](https://leanprover.zulipchat.com/#narrow/stream/217875-Is-there-code-for-X.3F/topic/How.20to.20simplify.20this.20proof.20without.20using.20a.20have.20statement.3F/near/422294189). As an example: ```lean example : 2^10 = eval% 2^10 := by -- goal is `2^10 = 1024` sorry ```
This is taken from my zulip message here.
As an example: