-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Pretty-print values in the REPL #9931
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
Conversation
|
Needs |
8395951 to
f5a7bb6
Compare
Pretty-print values in the REPL by printing each item in a list or
attrset on a separate line. When possible, single-item lists and
attrsets are printed on one line, as long as they don't contain a nested
list, attrset, or thunk.
Before:
```
{ attrs = { a = { b = { c = { }; }; }; }; list = [ 1 ]; list' = [ 1 2 3 ]; }
```
After:
```
{
attrs = {
a = {
b = {
c = { };
};
};
};
list = [ 1 ];
list' = [
1
2
3
];
}
```
f5a7bb6 to
c0a15fb
Compare
thufschmitt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great!
Left a few comments, and I'll leave a bit of time for others to chime in, but a bit 👍 overall
Co-authored-by: Théophane Hufschmitt <[email protected]>
|
A conceptual question on the side: couldn't we instead allow plugging a formatter as developed by @piegames and @infinisil? Otherwise we'd be duplicating effort. |
I briefly touched on that with @infinisil, but doing so would make the whole infra significantly more complex, and this formatting is only for values (and not arbitrary expressions), which makes it orders of magnitude simpler (the formatting change is around 60 extras loc) |
|
This could have a release note though. |
|
@fricklerhandwerk Good point, I've added a release note in #9943. |
Motivation
Pretty-print values in the REPL by printing each item in a list or attrset on a separate line. When possible, single-item lists and attrsets are printed on one line, as long as they don't contain a nested list, attrset, or thunk.
Before:
After:
Here's how the output looks (with #9928 and #9926 applied as well):

Context
@Qyriad's prototype pretty-printer in Xil gave me the inspiration to do this. It turns out the patch is pretty small, so here it is!
In the future, users should be able to customize how much is printed for large values. See #9942.
Priorities and Process
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.