F# fsi.AddPrinter: Does AddPrinter have ability to

2019-09-14 15:42发布

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.

标签: f# fsi
1条回答
\"骚年 ilove
2楼-- · 2019-09-14 16:25

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.

查看更多
登录 后发表回答