forEachWhere p f e is similar to forEach f e, but only applies f to subterms that satisfy the
(pure) predicate p.
It also uses the caching trick used at FindExpr and ReplaceExpr. This can be very effective
if the number of subterms satisfying p is a small subset of the set of subterms.
If p holds for most subterms, then it is more efficient to use forEach f e.
@[inline]
Equations
- Lean.ForEachExprWhere.cacheSize = 8192 - 1
Implements caching trick similar to the one used at
FindExprandReplaceExpr.Set of visited subterms that satisfy the predicate
p. We have to use this set to make surefis applied at most once of each subterm that satisfiesp.checked : Lean.HashSet Lean.Expr
Instances For
Equations
- Lean.ForEachExprWhere.initCache = { visited := mkArray (USize.toNat Lean.ForEachExprWhere.cacheSize) (cast Lean.ForEachExprWhere.initCache.proof_1 ()), checked := ∅ }
@[inline]
abbrev
Lean.ForEachExprWhere.ForEachM
{ω : Type}
(m : Type → Type)
[inst : STWorld ω m]
[inst : MonadLiftT (ST ω) m]
[inst : Monad m]
(α : Type)
:
Equations
unsafe def
Lean.ForEachExprWhere.visited
{ω : Type}
{m : Type → Type}
[inst : STWorld ω m]
[inst : MonadLiftT (ST ω) m]
[inst : Monad m]
(e : Lean.Expr)
:
Equations
- One or more equations did not get rendered due to their size.
def
Lean.ForEachExprWhere.checked
{ω : Type}
{m : Type → Type}
[inst : STWorld ω m]
[inst : MonadLiftT (ST ω) m]
[inst : Monad m]
(e : Lean.Expr)
:
Equations
- One or more equations did not get rendered due to their size.
unsafe def
Lean.ForEachExprWhere.visit
{ω : Type}
{m : Type → Type}
[inst : STWorld ω m]
[inst : MonadLiftT (ST ω) m]
[inst : Monad m]
(p : Lean.Expr → Bool)
(f : Lean.Expr → m Unit)
(e : Lean.Expr)
:
m Unit
Expr.forEachWhere (unsafe) implementation
Equations
@[implemented_by Lean.ForEachExprWhere.visit]
opaque
Lean.Expr.forEachWhere
{ω : Type}
{m : Type → Type}
[inst : STWorld ω m]
[inst : MonadLiftT (ST ω) m]
[inst : Monad m]
(p : Lean.Expr → Bool)
(f : Lean.Expr → m Unit)
(e : Lean.Expr)
:
m Unit
e.forEachWhere p f applies f to each subterm that satisfies p.