Skip to content

refactor: create an intermediate 'VersoDoc' data structure - #594

Merged
robsimmons merged 11 commits into
mainfrom
intermediate-verso-doc
Oct 28, 2025
Merged

refactor: create an intermediate 'VersoDoc' data structure#594
robsimmons merged 11 commits into
mainfrom
intermediate-verso-doc

Conversation

@robsimmons

@robsimmons robsimmons commented Oct 26, 2025

Copy link
Copy Markdown
Collaborator

A VersoDoc genre is intended to represent an unevaluated Part genre. The result of a #doc command stops being syntax denoting a value of type Part genre, and becomes syntax denoting a value of type VersoDoc genre.

Presenting this indirection layer allows us for more flexibility in serializing some or all of a document in a way that minimally affects existing code. There are two alternative designs here that I considered:

  1. Having VersoDoc.toPart be monadic (returning m (Part genre) instead of Part genre), since we might in the future want to have a part that includes a reference to an auxiliary file or data structure. Doing this seemed like it would require much more substantial changes to existing code.
  2. Having VersoDoc.toPart require an extra argument, a piece of context that can be threaded through that might represent something like serialization data in the future. This would be somewhat simpler to implement (it would be implementing the reader monad instead of an arbitrary monad).

Comment thread src/verso-blog/VersoBlog/LiterateModuleDocs.lean Outdated
@robsimmons

Copy link
Copy Markdown
Collaborator Author

!bench

@leanprover-radar

leanprover-radar commented Oct 27, 2025

Copy link
Copy Markdown

Benchmark results for c2a8615 against c15ef5d are in! @robsimmons

Major changes (3)
  • refman-no-opt-args/compile//success changed.
  • refman-o0/compile//success changed.
  • refman/compile//success changed.

@Garmelon

Garmelon commented Oct 27, 2025

Copy link
Copy Markdown
Contributor

By the way, the results of this benchmark run may not be comparable because it's using the bundled clang.

Edit: I think the parent commit has already been re-run, so you can disregard the warning.

Comment thread src/verso/Verso/Doc.lean Outdated
Comment thread src/verso/Verso/Doc.lean Outdated
Comment thread src/verso/Verso/Doc.lean
/--
Replace the metadata in a VersoDoc.

This is something of a hack used as a workaround in LiterateModuleDocs.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like something we should be able to dispense with... What about moving the metadata line higher up in that file?

Comment thread src/verso/Verso/Doc/Elab/Monad.lean Outdated
Comment thread src/verso/Verso/Doc/Elab/Monad.lean Outdated
Comment thread src/verso/Verso/Doc/Concrete.lean Outdated
github-merge-queue Bot pushed a commit that referenced this pull request Oct 27, 2025
#594 (#598)

By creating an identity function `Part.toPart`, it's possible to have
code that works for both Verso versions where `#doc` creates a `Part
genre` and code that works with Verso versions where `#doc` produces
code of type `VersoDoc genre`, as introduced in #594
github-merge-queue Bot pushed a commit to leanprover/reference-manual that referenced this pull request Oct 28, 2025
This change uses the temporary functions introduced into Verso alongside
leanprover/verso#598, but it will remain is compatible with Verso after
the `VersoDoc` intermediate data structure being introduced
leanprover/verso#594 is merged.
@robsimmons
robsimmons added this pull request to the merge queue Oct 28, 2025
Merged via the queue into main with commit 736fe8e Oct 28, 2025
4 checks passed
@robsimmons
robsimmons deleted the intermediate-verso-doc branch October 28, 2025 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants