roc-lang / roc

A fast, friendly, functional language.
https://roc-lang.org
Universal Permissive License v1.0
4.37k stars 308 forks source link

Better debugging tools for typechecking #2486

Open ayazhafiz opened 2 years ago

ayazhafiz commented 2 years ago

Debugging the checker today is not the most pleasant thing in the world. First you must have a good understanding of how it behaves, and even then, you must spend some time searching and debugging errors. You can either put prints everywhere or use rr, but either way it's not great.

We can do better. It'll improve our lives and those of new contributors. We should expect that the bugs we come across will increasingly be less of the "simple" ones where someone realizes an edge case was missed, and more of the kind of cross-cutting subtleties that are impossible to predict.

The most useful first step IMO is having a tool that will generate a graph of the state of subs at any point in time. basically we just need to define a graphviz exporter for subs and Content. Then we can link this up with changes to subs, etc. I know how to do the graphviz exporting, that's not too hard - I have no idea how to make a UI for this. The graph will be very large so it'd be nice to be able to scroll through it, zoom in and out, etc.

Anyway, I'm looking for help on this. If you have some ideas on design or implementation please let me know!

rtfeldman commented 2 years ago

When you say a UI for this - do you mean a UI for exporting to graphviz at the right moment? Or a UI for exploring graphiviz data?

ayazhafiz commented 2 years ago

The latter. The former can be a flag, if enabled we'll capture a trace of how subs changed over time and then it'd be nice to view the trace in a UI

ayazhafiz commented 2 years ago

I don't want to export graphviz to eg a PDF directly because the graph will be very large and ): to look at, and the time-traveling aspect of this is really valuable