I was writing some F# code this week and ran into problem. Consider the following code:
type Thingey = This | That | SomethingElse
Which looks like an enum. So I assumed that, like things inheriting from System.Enum, an instance of the type had a ToString method which did the right thing. But, alas, when I type it into the F# Interactive Console I get:
> (Thingey.That).ToString();;
val it : string = "FSI_0002+Thingey"
The reason being is that the type Thingey is actually a Discriminated Union. In F#, to produce an Enumeration type you use the same syntax except you must explicitly provide an integer value for each member. Discriminated Unions can do a lot more than Enums in F#, but there are situations in which to use both.
The following snippet shows you how to use Enums and simple Discriminated Union types in F#.