Printing F# discriminated union
Have you tried printfn "%A" ast
? The %A
specifier takes into consideration the StructuredFormatDisplayAttribute
[MSDN], if present.
To convert a discriminated union into a string, you should use sprintf "%A" ast
instead of ast.ToString().
If you want Enum.GetName, you can use Microsoft.FSharp.Reflection
namespace. See What is the Enum.GetName equivalent for F# union member?.