Which pretty print library? [closed]

主宰稳场 提交于 2019-12-02 20:03:27

In no particular order:

  • The "Free" in Text.PrettyPrint.Free means free monad, as per the package description: "A free monad based on the Wadler/Leijen pretty printer"; its Doc type is parametrised on another type, and it has a Monad instance, allowing you to embed "effects" into Doc values. This is used by wl-pprint-terminfo to add formatting functionality; it's not not a competing package, but rather an extension library by the same author. See the list of additions in wl-pprint-extras' documentation compared to wl-pprint's list for more detailed information on what it adds.

  • wl-pprint-terminfo uses the terminfo package to do formatting, so it'll only work on POSIX-y systems, whereas ansi-wl-pprint uses the ansi-terminal package, so it'll work on Windows.

  • wl-pprint-text might be useful if you're working with Text already, but it's unlikely to have a major performance impact unless you're using the pretty printer really heavily; it's not exactly a massively computationally-intensive task.

Unless I had specific requirements, I'd probably just use the pretty package, since it's one of the boot packages, and thus available everywhere. I'd go for ansi-wl-pprint if I wanted formatting, and wl-pprint-text if I was working with Text, but otherwise I don't really see a particularly compelling reason to use a third-party library.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!