leanprover / leanprover/lean4

Clarify `Expr.forEachWhere`

Open
#2,511 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation P-low
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

As noted in #2491, the function docstring does not sufficiently explain its difference to forEach and in what circumstances one should use it. The module docstring gives more details, but is still misleading: it does not even mention the, I believe, main property of the function, f being applied at most once to each (structurally equal) subexpression. Thus a much more relevant question as to whether the function should be used might be whether f is much more expensive than p plus expr hashing.

Thus I propose to first confirm and document the intent of the function as well as consider renaming it (such as to forEachOnceWhere) before considering any refactors on top of it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the Expr.forEachWhere function and its surrounding module and function docstrings. Read the references in #2491 and verify the intended distinction from forEach, especially the at-most-once behavior for structurally equal subexpressions. Done means the intent and usage guidance are accurate, with any rename decision recorded.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.