本文介绍了哪个漂亮的打印库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




  • 美丽的古老的HughesPJ

  • wl-pprint-extras

  • wl-pprint-terminfo

  • wl-pprint

  • ansi-wl-pprint

  • wl-pprint-text



6? 6个漂亮的打印库......不用等,我们再来。



无论如何,除了HughesPJ,他们都是Wadler-Leijen。我的理解是WL更简单更快,所以可能是新代码的首选。



wl-pprint和wl-pprint-extras似乎是相同的...我无法说出后者有什么额外,或者说Free在这里意味着什么(模块是Text.PrettyPrint.Free)。



wl-pprint- terminfo和ansi-wl-pprint都似乎是ANSI终端颜色和whatnot的变体,并且似乎等同于wl-pprint-terminfo没有任何文档。



wl-pprint-text当然使用文本。我不知道实际速度有多大差别。



令我担忧的是,他们中的很多人都有很多发行版。这意味着他们已经添加了功能,修正了错误等等。但是他们是否都修复了相同的错误?我倾向于支持ansi-wl-pprint,因为它有文档,最后一次上传是在2012年,并且有一些版本,这意味着作者仍然在使用它。



但我不确定。任何人有任何建议?我相信其他人都同意,5个几乎不太完美的复制粘贴模块可以进行一些整合...... 解决方案

解决方案

没有特定的顺序:


  • 中的FreeText.PrettyPrint.Free 意味着,根据软件包描述:基于免费monad在Wadler / Leijen漂亮的打印机上;它的 Doc是在另一个类型上进行参数化的,它有一个 Monad 实例,允许你将效果嵌入到文件值。这由wl-pprint-terminfo用来添加格式化功能;它不是一个竞争性的软件包,而是同一作者的扩展库。请参阅与包来做格式化,所以它只能在POSIX-y系统上运行,而ansi-wl -pprint使用软件包,因此它可以在Windows上运行。 Text ,那么wl-pprint-text可能会很有用,但它不太可能除非您真的使用漂亮的打印机,否则会对性能产生重大影响;它不完全是一个大量计算密集型任务。




除非我有特殊的要求,否则我可能只是使用漂亮的软件包,因为它是引导软件包之一,因此随处可用。如果我想格式化,我会选择使用ansi-wl-pprint,如果我使用 Text ,则使用wl-pprint-text,但除此之外,我没有看到特别强调使用第三方库的理由。


So from a glance at hackage I can see 5 pretty printing libraries:

  • good old HughesPJ in pretty
  • wl-pprint-extras
  • wl-pprint-terminfo
  • wl-pprint
  • ansi-wl-pprint
  • wl-pprint-text

Oh wait, was that 6? 6 pretty printing libraries... no wait, we'll come in again.

Anyway, they're all Wadler-Leijen except of course HughesPJ. My understanding is that WL is simpler and faster, so is probably preferred for new code.

wl-pprint and wl-pprint-extras seem to be the same... I can't tell what's "extra" about the latter, or what "Free" means here (the module is Text.PrettyPrint.Free).

wl-pprint-terminfo and ansi-wl-pprint both seem to be variants with ANSI terminal colors and whatnot, and seem equivalent except that wl-pprint-terminfo doesn't have any docs.

wl-pprint-text, of course, uses Text. I don't know how much difference that actually makes wrt speed.

The thing that worries me about these is that many of them have many releases. This implies they've had features added, bugs fixed, etc. But have they all had the same bugs fixed? I'm inclined to favor ansi-wl-pprint because it has documentation and its last upload was in 2012, and has a bunch of releases which implies the author still works on it.

But I don't know for sure. Anyone have any advice? And I'm sure others agree that 5 almost-but-not-quite copy-paste modules could do with some consolidation...

解决方案

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.

这篇关于哪个漂亮的打印库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 03:31