Repository navigation
djot.v: a verified djot parser, and a way to check syntax extensions #414
Replies: 4 comments
|
Very interesting! I'd be curious about the performance of the Haskell program as compared to my own Haskell implementation, jgm/djoths. |
|
I did a simple benchmark. On a Macbook Pro with Apple Silicon with GHC 9.6.4 ( Details
All extractions pass In short, on large documents, Haskell extraction with The OCaml extraction has a few optimization. If all those tricks are ported to the Haskell extraction step, I estimate the performance will be around 1-1.5x slower than |
|
Interesting. I tried some combinations beyond the existing conformance cases and found a small footnote mismatch in the packaged OCaml parser at Current djot.js ( The syntax reference explicitly allows lazy continuation of footnote paragraphs. Adding one space before I packaged those controls and the failing cases in a four-case conformance fixture, with outputs and reproduction commands. The I also checked the failing block shape and the indented control directly in Rocq; both witnesses close without axioms. This looks like a useful case to add alongside the existing suite. It also illustrates a boundary of the current guarantees: passing the quote/list uniformity checks doesn't cover every container's continuation behavior. |
|
Thanks @dereuromark, this is a real missing point. I've added a new property about lazy line continuation.
The added missing theorem (a line that continues an open paragraph parses exactly as the same line with the containers' prefixes written out), together with the container uniformity, should now cover documents with lazy lines. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi, I've written a djot implementation in Rocq, djot.v. Rocq is a dependently typed theorem prover. I used it to state djot's design goals as theorems and prove them. The main ones (from djot's rationale and the Beyond Markdown post):
[foo][bar]is a link does not depend on whetherbaris defined.The parser matches
djot.js's test suite on all HTML cases.What
djot.vverifies is actually a family of syntax settings, and the official djot (specified by the syntax reference) is one setting of this family. Each setting comes with an answer to which of the properties above it keeps. The point is that extensions and dialects can be checked before they are adopted: either they keep every guarantee, or we know exactly which one they give up and can decide whether the tradeoff is worth it. For example, writing strong emphasis as**instead of*keeps every property. Letting a list interrupt a paragraph, so a sublist no longer needs a blank line before it, costs safe hard-wrapping and nothing else.I think many proposals for new syntax could be tested this way, in Rocq or any other prover. It would give us common ground for discussing which properties a proposal keeps and whether two extensions are compatible.
Rocq can extract programs to OCaml, Haskell and Scheme. The OCaml extraction is packaged as a library with a tuned API and has had performance work. The other two targets are possible but untested.
Edit 2026-10-05: I made a site that has a playground (with extension as checkboxes), the reference for the extensions, and the OCaml API docs.
All reactions