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

Support for paging #5

Open
justone opened this issue Mar 28, 2018 · 4 comments
Open

Support for paging #5

justone opened this issue Mar 28, 2018 · 4 comments

Comments

@justone
Copy link

justone commented Mar 28, 2018

Hey,

datawalk is great, I used it to investigate a rather large data structure today, and it helped a lot.

One limitation I ran into was that my data structure has 95 (or so) elements in the list, and so when I loaded up datawalk, I had to keep guessing at the last index (the one I wanted to see). I ended up using the ! function to run last on the collection, but I was wondering: would it be useful to add paging to the repl so you can see elements 30-59, and so on?

Thanks again for datawalk.

@eggsyntax
Copy link
Owner

Hi,

Thanks for your comments and feedback! Glad datawalk has proved useful for you :)

Paging is a terrific idea! I'll have to give it some thought -- I've tried to find a balance between simplicity/ease-of-use and power, so I'm pretty cautious about adding more commands. But it'd definitely be a nice feature to have, and not one I've considered before. For me, I'm usually using it to explore data where I care more about examining a representative element (per level) rather than seeking out a specific element. But it seems plausible that there are plenty of folks with your use case.

Any thoughts about the value of next-page/previous-page commands vs jump-to-nth command?

I'm unavailable for a few weeks, but I'll add it to my calendar to come back & think more about this issue when I get back.

@tkocmathla
Copy link

I agree that paging would be a useful feature. For my purposes, it would be enough to just have next/previous page commands.

I didn't know about the ! function before seeing this issue, but for others that want this feature before it's implemented, you can approximate paging (in one direction) like:

[datawalk] > !
Please enter a function of one variable
Enter a fn >> (partial drop 30)

@eggsyntax
Copy link
Owner

Thanks to both of you for the input. I'm feeling good about adding this feature, but it's likely to be a good while before I have a chance (just changed jobs, and things are really busy right now). I'm open to a pull request adding paging, if either of you (or someone else) feel motivated to add it. Otherwise I'll get to it when I can!

The tricky part will be that page-back attempts to visit data that's not a substructure of the current data structure. It probably makes more sense to only add a page-forward function, and let the user rely on the backward command (ie backward-in-history) to reverse that. But I'm open to input on that approach.

Adding it will be a matter of:

  • Adding a page-forward function in datawalk.datawalk which drops n items from the current data structure (probably n = :max-items in datawalk.print/config).
  • Adding > to datawalk.parse/cmd-map, mapped to the page-forward fn.
  • Adding a description in datawalk.datawalk/help-text.

Offhand I think that's everywhere.

@eggsyntax
Copy link
Owner

Alternately, it might be worth adding an additional state atom in datawalk.datawalk, containing a map from current data to previous page, and then having a page-backward fn which returns that, bound to <. I'm slightly more hesitant on that approach, only because I've tried to limit the amount of state that datawalk maintains, but I'm potentially open to it.

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

No branches or pull requests

3 participants