-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Literate Agda using markdown #680
Comments
@WhatisRT what do you think? Also, can you maybe mark this as "discussion" I'm missing permissions. |
Probably out of scope of this right away, but plfa also does a GREAT job in getting people started on setting up tools and guiding them to contribute (both are just markdown files in their repo too). |
I could go either way on this. Both approaches have benefits and drawbacks, and to a large degree the original decision to go with LaTeX was just based on precedent. Here are some tradeoffs:
As a consequence of LaTeX giving us more options to display things, the document can be further removed from technical Agda issues we might be having. For a recent example, we had some instance resolution issues here and really the only solution is to replace a function by a type. With a bit of creative post-processing, we can just put a 'newtype' wrapper around our function and then just disappear the wrapper when rendering. So for documentation purposes we basically just pretend the original code works, even if it doesn't for technical reasons. I'm not so sure if we can do the same level of post-processing with Markdown (and it would probably destroy links?), so we might have to actually replace the function with a relation in the visible part of the documentation in this case. There are probably tens of cases where we would have a different visible code if we couldn't hide our dirty little secrets so well. Also, we currently have this generated HTML that we link from the README, which is just generated from the same source as everything else. It's a big mess because it has all the LaTeX code in it, but at least it has working links for everything. I guess we could have some kind of parallel documentation in Markdown that replaces this if we wanted to. |
One middle-ground that I'd highly recommend exploring is Typst. It's essentially markdown, with a rust-like embedded DSL for rendering / layout / computation. It feels like a modernized LaTeX, is an absolute delight to work with, and has all of the pro's listed above. We use this to typeset our audits. For an example, here's one of the audit reports we've made public: https://github.com/SundaeSwap-finance/sundae-audits-public/blob/main/butane-sale/butane-sale.typ and here's the rendered result: https://cdn.sundaeswap.finance/audits/butane-sale.pdf It also looks like it's already supported by Literate Agda: https://agda.readthedocs.io/en/nightly/tools/literate-programming.html#literate-markdown-and-typst |
@Quantumplation while I am intrigued by Typst myself and could be an improvement, it does not address my issue in full. Particularly "drive-by contributions" are similarly unlikely as with LaTeX or other niche markup languages like @WhatisRT Thanks for outlining the pros of the status quo and how Markdown could improve the situation - I agree with your benefits listed. Can we make the pros for LaTex (= cons for markdown) more concrete? I'm not convinced that they are even an issue with the source markup used.
It's not my intention to deny this (within this issue) and I'm quite sure PDF output is possible, but could require some work (quoting a colleague of ours "pandoc exists!!") If we look at plfa again, they have an EPUB export but also an open issue about PDF. I'd be happy to investigate and see whether I can solve it for them to unblock us here?
I'm sorry, but which vectors? After searching through the repository I found some heave post-processing related to the term "vector", which seems to be related to
Any specific formatting you would be missing from markdown? I don't see a bibliography used in the current ledger specs pdf, but as we would most likely use pandoc (as recommended by the agda docs) to produce a PDF with a bibliography .. citations and
Can you point me to something concrete for this? It sounds like we want to aggregate the same source files into two or more outputs. I'm not sure why you would assume this is not possible with
I could not follow this example of yours. Is this maybe captured by having code rendered but ignored by agda (or the other way around)? The agda docs mention that this is possible and I saw it used on plfa too.
This HTML? You are right, it's a mess and the tex code makes it hard to navigate. I do understand that for plfa a similar method for producing HTML output was used.. just that the actual book is this HTML rendering. For example this chapter which even contains links to other places in the book or the agda standard library (click on stuff in the import list!). Ironically, the discussion in #677 yielded another Pro for Markdown:
The contribution of @Quantumplation in the other issue is a perfect example of that. If we would be using markdown, we could really just copy that into our sources or he might have been even inclined to open a PR onto that Sorry for the long comment, but I thought writing things down is most helpful. I'd be happy to also chat more informally about this soon! |
Note we've had good success rendering literate markdown Agda code in the Peras project: https://peras.cardano-scaling.org/agda_html/Peras.SmallStep.html And there's always |
Plus the HTML has hyperlinks so one can jump around to definitions of things very easily |
I think the point I was making is that Typst does increase the likelihood of "drive-by-contributions", because the bulk of the document is just markdown. Someone can write a whole section in markdown and it will render as they would expect. And then, as it gets refined/edited, or if they're familiar with it, you can make that content richer by leveraging the Typst to typeset formulas, render diagrams, or even run computation a la literate agda. (that being said, I'm not trying to push hard for Typst, just wanted to share it as an option that I think meets your goal, while also giving contributors the flexibility to typeset to their hearts content) |
Yeah, maybe we can also get this from markdown. If you want to investigate this go ahead! It might be quite useful either way.
See for example this screenshot which I had lying around: It's a huge record update, and it'd be a lot less readable in any other form I can think of. We use this a lot in the STS rules as well.
Nothing other than the vertical vectors comes to mind right now, but I'm sure there are a couple of things you'd bump your head into when moving from one to the other. Both PDF specs have a bibliography, it's just not visible in the TOC which it probably should. It's right before the appendices.
We have
It's not just about hiding code fragments, it's about somewhat arbitrarily tweaking code slightly when rendering it. In Agda, you want for example
Yeah, that's it. We also generate HTML from more sane sources in our dependencies, so I'm familiar with the method. It's just that we went with the PDF and the HTML is just a minor thing that I set up once in an hour and is only rarely used for communication purposes.
Yeah, that's probably right. I guess it's not another pro since it falls under 'easier to contribute' but it's definitely a great example of that. |
I think we might as well consider Typst, it seems like a middle-of-the-road approach. Though I think it could also be the case that it just turns out to not have the pros of either side, being less approachable than Markdown while also being less powerful than LaTeX. Maybe it would be a good idea to make a document that shows the strengths of each approach? We have this super old document that I produced as a showcase that literate Agda would work: https://github.com/IntersectMBO/formal-ledger-specifications/blob/ffcbb7d9cd29f8acf02cf4e27557a19a5b7fe2af/Ledger.pdf Maybe this one is too easy because it doesn't have all the complexity that we now somewhat require, but it might be a good idea to do a more sophisticated variant of that as a demo. |
Opening this issue as I would like to discuss whether there is a chance to create the formal-ledger-specifications as a set of literate Agda documents using markdown instead of LaTeX.
Why
As an occasional reader of the
formal-ledger-specfications
I want to be able to contribute to it by fixing typos, fixing links or even suggesting "prose" and explanations to make certain dense concepts more easier to understand to readers. i.e. this request is not about the Agda code itself.While I know how to write LaTeX, I prefer using less distracting formats like markdown or restructured text. As I post this issue here in Github, I am typing it in (github flavored) markdown and hence this feels most familiar to me as a software engineer.
Furthermore, as a "casual contributor" I might be even reading the specification and when finding a small issue like a typo, I would not have the repo checked out, but prefer to "edit in github" (there are links like this often in rendered documents to invite collaborators).
What
Should we use Literate Markdown to write the Ledger specs?
Example
I really like how the Programming Language Foundations in Agda book is presented and when I briefly worked on it in a workshop it was very easy to contribute to as it is just Markdown + Agda code blocks. The pull request even rendered a nice "rich" diff: https://github.com/plfa/plfa.github.io/pull/878/files#diff-2a2528d7e68ace2c2a17503f240dc0933d52fadf03cdab452b34a513bf6ebfca.
With literate markdown, Github helps me to access and re-orient myself in the corresponding source file. Compare this section from plfa:
https://github.com/plfa/plfa.github.io/blob/dev/src/plfa/part1/Induction.lagda.md
Screenshot plfa
Versus this section from this repo:
https://github.com/IntersectMBO/formal-ledger-specifications/blob/master/src/Ledger/GovernanceActions.lagda
Screenshot formal-ledger-specifications
The text was updated successfully, but these errors were encountered: