Closed BlakeHepner closed 6 years ago
Thanks good idea! I've added the function you suggested and some related functions (ppShowList
, and ppDocList
). The only difference is that the result is printed as a list (i.e., with square brackets and commas in between). I chose to do it that way, because one of the goals of pretty-show
is that the output is standard Show
compatible as much as possible, but also human readable.
The new version should be on hackage, 1.6.14. Let me know if you find any issues.
So I have no idea how to make a pull request with git/github, but adding this function is likely easier this way anyways:
Currently, if you pPrint a list-like object, it requires the whole object to be loaded into memory before any of it will print, even if the underlying list-like object can be streamed. After a bit of trial and error, I made the following function which can pretty print any list-like object efficiently. I was wondering if you could add it to your library:
toList
is from Data.Foldable,unlines
is from the Prelude.To give an idea of usage:
on a list of numbers [1..1000000]
using pPrint on it directly will consume ~1.4GB of memory at max.
While using pPrintList will consume only ~1MB of memory at max.
pPrintList used:
pPrint directly applied: