I have some data structure which are several levels deep and produce extremely long and skinny pretty printed output. It would be desirable, if only the first level (generally n levels) would prettyprint and the rest shown in the regular compact format.
I looked at the various pretty-printer on hackage, but could not find one with a functionality to pretty-print structured records up to a specified depth. Is there such a tool or how can it be constructed?
I have some data structure which are several levels deep and produce extremely long and skinny pretty printed output. It would be desirable, if only the first level (generally n levels) would prettyprint and the rest shown in the regular compact format.
I looked at the various pretty-printer on hackage, but could not find one with a functionality to pretty-print structured records up to a specified depth. Is there such a tool or how can it be constructed?
Share Improve this question asked Feb 3 at 21:56 user855443user855443 2,9485 gold badges32 silver badges45 bronze badges 2 |1 Answer
Reset to default 0One possible line of attack: look at prettyprinter
. It renders documents to an intermediate form called SimpleDocStream
. So you might try writing a renderer which either counts the stack depth or limits the indent width. Not exactly what you asked for, but something like that sounds like it would solve your problem.
show
instance? (recursively passing down the nesting level and decreasing it by one each time) – mb21 Commented Feb 4 at 10:33