F#fsi.AddPrinter:AddPrinter是否有能力将列表分开? [英] F# fsi.AddPrinter: Does AddPrinter have ability to take list apart?
问题描述
在我们的项目中,我们使用fsi.AddPrinter
来打印类型formula<fol>.
In our project we use fsi.AddPrinter
for printing type formula<fol>.
为了更加容易,我们在fsx文件中加入了fsi.AddPrinter sprint_fol_formula
,以便将AST结果转换为人类可读的结果.
To make it easier we include fsi.AddPrinter sprint_fol_formula
in our fsx files to transform the AST results into human readable results.
val inline sprint_fol_formula : formula<fol> -> string
在创建测试用例的过程中,我们还输出AST结果和人类可读的结果.
In the process of creating test cases we also output both the AST result and the human readable result.
AST结果是处理公式的结果.要在单元测试中将AST转换为人类可读的格式,我们只需使用sprint_fol_formula astResult
.
The AST result is the result of processing the formulas. To transform the AST into human readable format in the unit test we just use sprint_fol_formula astResult
.
现在,如果结果是formula<fol> list
而不是formula<fol>
,则在使用FSI时将输出正确的结果,但是sprint_fol_formula
不接受formula<fol> list
.
Now if the result is formula<fol> list
instead of formula<fol>
, the correct result will be output when using FSI, but sprint_fol_formula
does not accept formula<fol> list
.
对于差异,我唯一可以得出的合理答案是fsi.AddPrinter
具有内置功能,可以将列表分开,然后分别打印每种类型.
The only reasonable answer I can conclude for the difference is that fsi.AddPrinter
has the built-in ability to take a list apart and then print each type individually.
是真的,还是我错过了什么?
Is this true, or did I miss something?
如果是这样,您可以在记录了此内容的地方添加引用吗?
If this is true, can you add a refernce where this is documented.
推荐答案
发生的事情很简单.有一个用于'a list
的打印机,它打印列表中的每个元素(或仅打印第一个元素,具体取决于它们的文本长度和列表的长度),并对其进行很好的格式化([ _; _; _; ... ]
.当打印项目时,它使用您的打印机.
What happens is quite simple. There is a printer for 'a list
, which prints each element in the list (or only the first ones, depending on their textual lengths and the list's length), and formats it nicely ([ _; _; _; ... ]
. When prints the items, it uses your printer.
这篇关于F#fsi.AddPrinter:AddPrinter是否有能力将列表分开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!