F# fsi.AddPrinter: Does AddPrinter have ability to take list apart?

我们两清 提交于 2019-12-25 00:27:10

问题


In our project we use fsi.AddPrinter for printing type formula<fol>.

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

In the process of creating test cases we also output both the AST result and the human readable result.

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.

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.

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.


回答1:


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.



来源:https://stackoverflow.com/questions/13893375/f-fsi-addprinter-does-addprinter-have-ability-to-take-list-apart

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