chore: turn on new do elaborator in Core#12656
Conversation
b4f91ed to
78682df
Compare
|
!bench |
|
Benchmark results for 78682df against e7e3588 are in! @sgraf812
Large changes (2✅)
Medium changes (79✅, 1🟥) Too many entries to display here. View the full report on radar instead. Small changes (837✅, 17🟥) Too many entries to display here. View the full report on radar instead. |
f93e9e4 to
5655b34
Compare
|
I looked into the only reported medium regression in #12656 (comment): ~+20% more instructions in Lean/Meta/Match/Rewrite.lean. It's not related to the do elaborator; it's LCNF taking more time, presumably to simplify away the |
5655b34 to
b27d73d
Compare
|
It's a bit unfortunate that there have to be so many adaptations regarding do let rec loop (i : Nat) (h : i ≤ as.size) (b : β) : m β := do
match i, h with
| 0, _ => pure b
| i+1, h =>Edit: Nice to see some good performance wins, though! |
|
Mathlib CI status (docs):
|
|
Reference manual CI status:
|
That's actually a good point. I opened #12673. |
Rob23oba
left a comment
There was a problem hiding this comment.
I'm not entirely sure why all of these changes are necessary, can you explain?
|
Also, is it planned that we get Example where it would be really nice to have ForInNew
import Lean
set_option backward.do.legacy false
open Lean Meta Elab Term
elab tk:"with_cont " fn:term : doElem <= dec => do
let combinator ← elabTerm fn none
let type ← inferType combinator
let .forallE _ t b _ ← whnfForall type | throwFunctionExpected combinator
let u := (← read).monadInfo.u
let cont ← withLetDecl dec.resultName (.const ``PUnit [u.succ]) (.const ``PUnit.unit [u.succ]) fun e => do
mkLetFVars #[e] (← dec.k)
let contTy ← inferType cont
unless ← isDefEq t contTy do
throwErrorAt tk "error"
let res := (← read).doBlockResultType
let monad := (← read).monadInfo.m
let expect := .app monad res
unless ← isDefEq b expect do
throwErrorAt tk "other error"
return combinator.beta #[cont]
@[doElem_control_info doElemWith_cont_]
def controlInfoWithCont : Do.ControlInfoHandler := fun _ => pure .pure
def test (n : Nat) : ReaderM Nat Nat := do
for i in *...n do
with_cont withReader (· + 1)
read
#guard ((test 0).run 3).run == 3
#guard ((test 5).run 3).run == 8 -- fails :-( |
|
Yes, I agree that |
8cae8e1 to
d05cf36
Compare
This reverts commit 2f62915.
The helper function matched on `.packageFacet` instead of `.targetFacet`, causing `collectTargetFacetArray` and `collectSharedExternLibs` to never find any target facet jobs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
!bench |
|
Benchmark results for a922d86 against 333ab1c are in! @sgraf812
Large changes (3✅)
and 1 hidden Medium changes (75✅, 1🟥) Too many entries to display here. View the full report on radar instead. Small changes (818✅, 24🟥) Too many entries to display here. View the full report on radar instead. |
Rob23oba
left a comment
There was a problem hiding this comment.
Thanks, good to see the new do elaborator moving forward. One small question but otherwise everything LGTM. (also I just wanted to mention that I got one function from 7.5s elaboration time to 1s using the new do elaborator!)
Great! Thanks for the review and the benchmark :) Will merge once Mathlib reports back in green |
|
Mathlib CI status (docs):
|
This PR turns on the new
doelaborator in Init, Lean, Std, Lake and the testsuite.