I am writing a F# program which parses a string into a AST type which is a discriminated union.
When I use fsi
(on Mono + Mac OS X) to run my code, the AST is printed out in a nice format. But when I use printfn "%s" <| ast.ToString()
I get something like FSI_0002.Absyn+clazz
. Writing a ToString
method for all the discriminated union types would be a big chore.
How do I make the value print the way fsi
does it?
Have you tried printfn "%A" ast
? The %A
specifier takes into consideration the StructuredFormatDisplayAttribute
[MSDN], if present.