unisonweb / elm-browser

A Unison Github repo explorer in Elm
MIT License
34 stars 4 forks source link

Road to Release #60

Open nicklawls opened 4 years ago

nicklawls commented 4 years ago

Reading this in the last Unison blog post got me all jazzed up:

The idea is that you can hyperlink to any Unison definition, in any Git repo, and render that definition nicely with hyperlinks to all its dependencies. And rather than this being a build artifact that every library author must maintain and keep up to date, it's something that Just Works for all publicly hosted Unison code, without any action needed by library authors! It works by reading the underlying codebase format which has all the semantic information needed for this to be possible.

That said, having peeked back into the code here for the past few days, I'm unclear as to how far towards that goal everything is. I wanna ask some general questions here, and hopefully generate enough discussion to write up issues that will get this baby shippable.

francisdb commented 4 years ago

You might want to ask these questions in one of the unison slack channels https://www.unisonweb.org/community

nicklawls commented 4 years ago

Excellent suggestion @francisdb!

nicklawls commented 4 years ago

Made a separate issue to start tracking Docs rendering, which seems like some good low-hanging fruit

https://github.com/unisonweb/elm-browser/issues/65

Although handling builtin.Doc.Evaluate will be tricky!

pchiusano commented 4 years ago

Notes from discussion:

Going to focus on just having a viewer of individual definitions, which has very few unknowns and is also incredibly useful.

Some bikeshedding on URL format that we were just whiteboarding:

www.unisonweb.org/browse/(github|gitlab)/xilnocas/myunisoncode/latest/by-name/path/to/mydefinition
www.unisonweb.org/browse/(github|gitlab)/xilnocas/myunisoncode/<namespacehash>/by-name/path/to/mydefinition
www.unisonweb.org/browse/(github|gitlab)/xilnocas/myunisoncode/<namespacehash>/by-name/path/to/mydefinition
www.unisonweb.org/browse/(github|gitlab)/xilnocas/myunisoncode/<namespacehash>/by-hash/<hash>

Doc Evaluate nodes can just be rendered as links to the source of the definition being evaluated with some subtle indicator + tooltip about how the user can evaluate the definition locally.

Idea: Maybe the view page for a definition gives the UCM instructions for fetching that definition at the bottom. ("How do I get this definition?")

aryairani commented 4 years ago

We should use a URL format that supports git branches and git hashes and supports looking up definitions named /.

I recommend checking UriParser.hs for inspiration!

aryairani commented 4 years ago

Something like this should also work: https://github.com/unisonweb/unison/blob/c8e7f002a2d8858cdd961bbaa300ebc55318ee95/parser-typechecker/src/Unison/Codebase/Editor/UriParser.hs#L26-L55

nicklawls commented 4 years ago

I took a first crack at URLs based on @pchiusano's comment from last week.... didn't notice @aryairani's additions till afterward 😅

I can report that elm/url's parser API wouldn't let me parse arbitrary length paths (.../path/to/mydefinition), so I needed to resort to .path.to.mydefinition anyway. That pushes things pretty darn close to the format outlined in the link above, so maybe we should just go the rest of the way there for ecosystem consistency.

aryairani commented 4 years ago

It supports branch names, which are hard to parse without IO that literally checks for the existence of such a branch, because they can include ., /; everything but :, basically. :-\

And... I couldn't bring myself to not support git branches, given what a fundamental part of git they are.