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

"autoview", tables, new data formats... #1371

Open
dumblob opened this issue Jul 14, 2021 · 4 comments
Open

"autoview", tables, new data formats... #1371

dumblob opened this issue Jul 14, 2021 · 4 comments

Comments

@dumblob
Copy link

@dumblob dumblob commented Jul 14, 2021

It seems Elvish has a rather simlistic data types and thus also rather "raw" pretty printing.

Here I'd like to ask for opinions on something like Nushell does - namely it automatically inserts | autoview (interactive pretty printing with scrollbars, graphics support etc.) if there is no sink at the end of a pipeline. Moreover Nushell supports arbitrarily nested data types incl. nested tables of plenty of other data types.

I'd like to see this richer set of data types along with advanced "pretty printing" in Elvish. Any plans for that?

Somewhat related to pretty printing: #1149 (comment)

@krader1961
Copy link
Contributor

@krader1961 krader1961 commented Jul 14, 2021

FYI, Elvish supports nested data structures. Here I define a map that contains two keys: l's value is a list and m's value is a map with two keys:

> var m = [&l=[1 2 3] &m=[&k1=v1 &k2=v2]]
> pprint $m
[
 &l=	[
   1
   2
   3
  ]
 &m=	[
   &k1=	v1
   &k2=	v2
  ]
]

Loading

@dumblob
Copy link
Author

@dumblob dumblob commented Jul 14, 2021

Sure, that part was clear - sorry for my writing (I first wrote tables, but that'd imply no nesting in a colloquial understanding which wouldn't be true in case of Nushell, so I've added the mention of nesting).

Actually what autoview command in Nushell seems to do is to try hard to come up with two axis and then render data accordingly. This often resembles a table or a row vector or a column vector (with artificial names of columns & rows - but wait, these artificial names can then be also used to refer to them!) with cells showing the data (if it's a scalar) or a syntax how to access the given cell if it's a composite (i.e. nested) structure - often another table 😉.

So as an example JSON (a generic tree structure) can be easily visualized as a table (with nested structures in cells) 😮 - but it feels so intuitive despite it's not a table but a tree.

Loading

@krader1961
Copy link
Contributor

@krader1961 krader1961 commented Jul 19, 2021

@dumblob, I don't see how arbitrary data structures, such as in my previous example, can be meaningfully displayed as a table. The first Nushell documentation link I looked at, which documents the autoview command, does not include an example of what you are proposing. Can you share some links that show the behavior you want from Elvish?

I'm also ambivalent about automatically appending the equivalent of | autoview to any pipeline I run interactively. You wrote "if there is no sink at the end of a pipeline" but I consider my terminal's handling of anything written to it to be that byte stream sink. In no small part because the output might contain terminal escape sequences that affect the appearance of the data. If I want the data to be translated in some way before the terminal renders it I expect to have to explicitly transform the data. Such as by piping it through pprint. I'm uncomfortable with that being done implicitly, but then I started programming when dinosaurs roamed the Earth. 😄

Loading

@dumblob
Copy link
Author

@dumblob dumblob commented Jul 19, 2021

@dumblob, I don't see how arbitrary data structures, such as in my previous example, can be meaningfully displayed as a table. The first Nushell documentation link I looked at, which documents the autoview command, does not include an example of what you are proposing. Can you share some links that show the behavior you want from Elvish?

It's scattered throughout Nutshell's (highly unfinished) documentation. Feel free to read it all (yeah, sounds weird, but I can't explain it better as I'd need to copy past large part of it - it's the same problem as explaining user experience of some moderately advanced GUI).

I'm also ambivalent about automatically appending the equivalent of | autoview to any pipeline I run interactively. You wrote "if there is no sink at the end of a pipeline" but I consider my terminal's handling of anything written to it to be that byte stream sink. In no small part because the output might contain terminal escape sequences that affect the appearance of the data. If I want the data to be translated in some way before the terminal renders it I expect to have to explicitly transform the data. Such as by piping it through pprint. I'm uncomfortable with that being done implicitly, but then I started programming when dinosaurs roamed the Earth.

In my opinion this stems from the fact Nushell is not trying to be a shell for a terminal but a shell on its own (i.e. without any terminal dependency). Classical terminal (e.g. VT100) is for Nushell just one of many possible "gateways" conceptual-wise (not necessarily technical-wise).

So I think it's really about the mind shift between "more piping and less programming" (Nushell) and "more programming less piping" (Elvish). I'm too new to Elvish to make more claims or observations - I'm just exploring the options I have with Elvish and speaking up lound while I'm at it 😉.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants