Skip to content
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

Color type parameter nesting in show #50921

Open
rafaqz opened this issue Aug 15, 2023 · 6 comments
Open

Color type parameter nesting in show #50921

rafaqz opened this issue Aug 15, 2023 · 6 comments
Labels
display and printing Aesthetics and correctness of printed representations of objects.

Comments

@rafaqz
Copy link
Contributor

rafaqz commented Aug 15, 2023

Its common for single types to take up 5, 10, and even 100 lines in the REPL. But its hard to extract information from a wall of flat, same-colored text.

As an alternative to #50884, it may make more sense to color the depth of nesting in types, so type parameters are given the next color in sequence from the current type. It would have a similar result for MethodError and at the same time make all complicated types easier to read.

If we cycle say four colors, we could distinguish four levels of nesting, and subsequent nested layers would be clearly internal, while using the same colors. This seems harder to achieve than #50884, but I can PR if people like this idea.

@Seelengrab
Copy link
Contributor

I think that's going to be confusing with the per-module colors we currently print in stacktraces. People may assume the colors between these two (the message in a MethodError and the stacktrace following it) are correlated.

@Seelengrab Seelengrab added the display and printing Aesthetics and correctness of printed representations of objects. label Aug 15, 2023
@rafaqz
Copy link
Contributor Author

rafaqz commented Aug 15, 2023

What do you mean by per-module colors? But yes I just hacked a demo and its a bit too much.

And still, types are pretty hard read currently, making that easier would make debugging a lot more efficient.

@Seelengrab
Copy link
Contributor

Seelengrab commented Aug 15, 2023

I'm talking about #45069.

I do agree that large/deeply nested types are hard to parse visually. I don't think adding more colors to that is the solution though. That'll IMO just end up like a colorful mosaic, too noisy to parse visually.

@timholy
Copy link
Member

timholy commented Aug 15, 2023

I think the best way to solve this problem is with something like https://github.com/JuliaCollections/FoldingTrees.jl. I think it would be a small enough addition that we could perhaps add a foldable parametric type-printer directly to that package, but it might be better as a separate package.

@rafaqz
Copy link
Contributor Author

rafaqz commented Aug 17, 2023

How would FoldingTrees.jl or similar packages help with reading the types in error output or various other places we print them in the REPL?

Do you mean just to manually inspect one specific type that you have in a variable?

@timholy
Copy link
Member

timholy commented Aug 17, 2023

Right. And since we have err, it's just an ergonomics issue to capture a specific signature (or portion of a signature) from a specific frame and feed it into a future TypeInspector.jl package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects.
Projects
None yet
Development

No branches or pull requests

3 participants