I was not aware that type printers should provide for handling a list as input.
I advise you not to do so. If you do it, you break KISS principle and may surprise other team members with a strange way of displaying very standard 'T list
. Just provide a printer for 'T
and let F# Interactive figure out the rest.
You may consider this case
type Theorem = Axiom list
where you care about Theorem
and would like to display it in an appropriate way. Then it makes sense to define a printer so that a Theorem
is printed out as
:- axiom 1, axiom 2, ..., axiom n.
This example isn't a very good example because you probably prefer a type-safe solution
type Theorem = Theorem of Axiom list
That said, you may ask whether you should go for fsi.AddPrinter
at all. The fsi.AddPrinter
bits may be there due to legacy reasons. More universal solutions are to override ToString()
methods and to use StructuredFormatDisplay attribute in order that you have good printers for both fsc
and fsi
, which work with printf "%A"
, printf "%O"
, etc.