admin管理员组文章数量:1305009
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.
本文标签: haskellPretty print only top n levels of a data structureStack Overflow
版权声明:本文标题:haskell - Pretty print only top n levels of a data structure - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741795817a2397933.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
show
instance? (recursively passing down the nesting level and decreasing it by one each time) – mb21 Commented Feb 4 at 10:33