datawalk icon indicating copy to clipboard operation
datawalk copied to clipboard

Support for paging

Open justone opened this issue 7 years ago • 4 comments

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.

justone avatar Mar 28 '18 01:03 justone

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.

eggsyntax avatar Mar 28 '18 02:03 eggsyntax

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)

tkocmathla avatar Oct 09 '18 14:10 tkocmathla

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 avatar Oct 23 '18 03:10 eggsyntax

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.

eggsyntax avatar Oct 25 '18 14:10 eggsyntax