How to enumerate a discriminated union in F#?
How can I enumerate through the possible "values" of a discriminated union in F#? I want to know if is there something like Enum.GetValues(Type) for discriminated unions, tough I am not sure over what kind of data I would enumerate. I would like to generate a list or array of a discriminated union with one item for each option. Yes, F# has it's own reflection layer build on top of .NET's reflection to help you make sense of types that are specific to F#, like discriminating unions. Here's the code that will let you enumerate a union's cases: open Microsoft.FSharp.Reflection type MyDU = | One |