Zulip Chat Archive

Stream: general

Topic: source code browser


Johan Commelin (Sep 03 2018 at 07:45):

Is there some way to easily turn a repo of Lean files into a hyperlinked bunch of HTML files? If we want to showcase some code to mathematicians, we should take into account that they have never heard of git or github before. Also, on github you can't click on an imported file, or a token, to go somewhere else. And we can't expect people who want to read some source files to install VScode before they are able to really use it.

Johan Commelin (Sep 03 2018 at 07:45):

So basically, I would like a read-only VScode that can easily be hosted somewhere. Just a bunch of static files.

Kenny Lau (Sep 03 2018 at 07:46):

I mean, for other languages (like Java) the corresponding website is grepcode

Kenny Lau (Sep 03 2018 at 07:46):

so I don't think things like this is very common

Soham Chowdhury (Sep 03 2018 at 07:51):

I think what @Johan Commelin has in mind is closer to Javadoc, Haddock, or agda --html.

Mario Carneiro (Sep 03 2018 at 07:52):

this has been a dream for some time

Mario Carneiro (Sep 03 2018 at 07:52):

My #explode command was actually working toward that goal

Johan Commelin (Sep 03 2018 at 07:53):

So, why is it easy in VScode?

Mario Carneiro (Sep 03 2018 at 07:53):

Currently it's a bit tough to get good data on what exists in a file

Johan Commelin (Sep 03 2018 at 07:54):

If VScode can figure out where to take me, if I Ctrl-click on something, can't it export a bunch of html files?

Mario Carneiro (Sep 03 2018 at 07:55):

Actually what you are describing sounds a bit different - the plan has been to show some abbreviated or expandable or indexed form of the file to make browsing easier

Johan Commelin (Sep 03 2018 at 07:55):

Ok, I guess that is harder.

Johan Commelin (Sep 03 2018 at 07:56):

I just figure that if Kevin publishes a paper, then he want to include a URL with a static view of his files that is easy to navigate.

Johan Commelin (Sep 03 2018 at 07:56):

GitHub isn't good enough.

Soham Chowdhury (Sep 03 2018 at 07:56):

It should be possible to dump source code into plain HTML files and then modify or hook into vscode-lean (I think) to use its symbol table to turn identifiers into links.

Mario Carneiro (Sep 03 2018 at 07:56):

I think Mizar has a pretty similar display to what you are suggesting, Coq too to some degree

Mario Carneiro (Sep 03 2018 at 07:57):

See, for example: http://www.mizar.org/version/current/html/polynom5.html#T74

Soham Chowdhury (Sep 03 2018 at 07:57):

https://agda.github.io/agda-stdlib/README.html
Just to be clear, @Johan Commelin, does this look like what you want?

Soham Chowdhury (Sep 03 2018 at 07:58):

Yeah, or that

Johan Commelin (Sep 03 2018 at 07:58):

Right, those are both good examples.

Johan Commelin (Sep 03 2018 at 07:59):

Althought the Agda one only has a bunch of comments and imports...

Soham Chowdhury (Sep 03 2018 at 07:59):

You can click on the imports to get to more interesting files.

Soham Chowdhury (Sep 03 2018 at 07:59):

Like this: https://agda.github.io/agda-stdlib/Category.Monad.html

Johan Commelin (Sep 03 2018 at 08:00):

I have very little fu in this regard. But it seems to me that it shouldn't be too hard to hack such a thing together, right?

Mario Carneiro (Sep 03 2018 at 08:01):

I really hope there is a more effective way to locate tokens than asking lean at each position what token is at that location (and where is it defined)

Mario Carneiro (Sep 03 2018 at 08:02):

otherwise this could take a really long time

Johan Commelin (Sep 03 2018 at 08:02):

Not longer then lean --make, right?

Johan Commelin (Sep 03 2018 at 08:02):

And this is something that you'll run only occasionaly.

Johan Commelin (Sep 03 2018 at 08:02):

So I really don't care about runtime.

Mario Carneiro (Sep 03 2018 at 08:02):

yes longer than lean --make

Johan Commelin (Sep 03 2018 at 08:03):

Ooh, hmmm

Mario Carneiro (Sep 03 2018 at 08:03):

I'm talking about asking lean at each character what is there, basically the software version of clicking everywhere to see what happens

Johan Commelin (Sep 03 2018 at 08:04):

But Lean stores this data already, right? We saw it sitting somewhere in some expr.

Johan Commelin (Sep 03 2018 at 08:04):

How does VScode figure this out? Only at runtime, when I click somewhere?

Mario Carneiro (Sep 03 2018 at 08:04):

Through the lean server API

Mario Carneiro (Sep 03 2018 at 08:05):

you click, VSCode sends lean a message asking "what is here", lean responds

Johan Commelin (Sep 03 2018 at 08:05):

I see. And that is going to be slow.

Mario Carneiro (Sep 03 2018 at 08:05):

if that is the only message you can send, then we are in trouble, but maybe there is a saner data structure being sent

Soham Chowdhury (Sep 03 2018 at 08:05):

Hm, isn't there a lexer/parser/AST-generator for Lean that we can hook into?

Mario Carneiro (Sep 03 2018 at 08:05):

see lean 4

Mario Carneiro (Sep 03 2018 at 08:06):

this is why many of the leandoc plans are waiting on lean 4

Johan Commelin (Sep 03 2018 at 08:07):

/me proposes :four_leaf_clover: as the default emoji for marking dreams and wishes that will be trivially realizable when Lean 4 emerges :stuck_out_tongue_wink:

Mario Carneiro (Sep 03 2018 at 08:08):

maybe we should make a list

Johan Commelin (Sep 03 2018 at 08:08):

Voila: https://leanprover.zulipchat.com/#narrow/search/.22lean.204.22

Johannes Hölzl (Sep 03 2018 at 08:54):

Apropos Lean 4: Leo gave a new talk at Galois inc. You find the slides on leanprover.github.io: http://leanprover.github.io/talks/LeanAtGalois.pdf Some new information about Lean4!

Johannes Hölzl (Sep 03 2018 at 08:54):

local constants are now called free variables :)

Patrick Massot (Sep 03 2018 at 08:54):

My Lean crawler does get access to some information. With more work we could maybe get something like what you want.

Johan Commelin (Sep 03 2018 at 08:58):

That would be really nice, Patrick!

Patrick Massot (Sep 03 2018 at 09:01):

I'm not sure it's worth the effort to fight Lean 3 here, but everyone should feel free to try

Reid Barton (Sep 03 2018 at 18:20):

I have a mostly working "API documentation" generator although I'm not sure yet that it is more useful than just reading the source files.

Reid Barton (Sep 03 2018 at 18:25):

I was hoping to look into how the editor integration works to see whether I could also produce hyperlinked source but I haven't gotten that far yet.

Johan Commelin (Sep 03 2018 at 18:28):

Cool! Please let us know if you get hyperlinking working!

Reid Barton (Sep 03 2018 at 18:42):

I do think probably the clearest use of such a tool is to advertise what we are doing in a way which is somewhat more transparent to people who are not already Lean users.

Johan Commelin (Sep 03 2018 at 18:44):

Right, and it might not be unthinkable that demand for such usage will increase in the next months. When the word spreads about the perfectoid project, and when more senior mathematicians hear about the teaching that Kevin and Patrick are doing.


Last updated: Dec 20 2023 at 11:08 UTC