leanprover / leanprover/lean4

Std.Http minor cleanups

Open
#15,051 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

While exploiting the long weekend and reading over the Std.Http code (which is very nice code!) I tweaked some things that I came across and, since the documented contribution flow involves creating an issue, I'm creating this. These changes hardly seemed worth individual issues, and barely seem worth this one. So please ignore this issue without comment, or copy any of this into your own ongoing changes, or whatever is more helpful.

  1. Dispatch pending requests immediately. This does seem to move the needle on serving trivial bodies by avoiding creating so many Tasks (per http_server_tcp.lean), and it's a very small change. (This is probably the least completely-useless change here.)
  2. Avoid String.toList at runtime. I think String.lean is converting to lists at runtime. (Although perhaps the compiler can optimise that away?) But it didn't seem to be necessary and it was a fun exercise to avoid it.
  3. IndexMultiMap.update rebuilds the whole map but doesn't need to. Since the shape of the structure isn't changed by mapping the values, a full rebuild can be avoided here.
  4. IndexMultiMap has required, but undocumented invariants. Likely excessive: I noticed that a couple of extra invariants were implicitly required here but not specified, so why not waste time showing that clearly true things are true? Quite possibly this just makes the code harder to change in the future.
  5. Drop a superfluous Open: utterly trivial, an already-open namespace is opened again.

AI: code edits are done by hand, proofs are not. Even in the simple cases where I can bumble through the proof in VS Code, the model can do it in one line. In #4, it also pointed out that I had carefully written a uniqueness invariant which was just a worse version of List.noDup.

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

Review the five linked commits and the referenced Std.Http areas, including http_server_tcp.lean, String.lean, and IndexMultiMap. Start by determining which cleanup the maintainers want to pursue; done means the selected change is integrated with its accompanying proof or validation and does not regress the affected HTTP behavior.

Written by the indexing model from the issue text.

Assessment

Domain
networking
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.