Use case to limit enumeration type F #?

According to the documentation, the restriction on the type of enumeration of the form : enum<underlying-type> "is not intended for general use." What will be the unusual use intended for this?

+4
source share
1 answer

The first thing that comes to mind is wrapping the System.Enum members with strongly typed shells:

 // gets all underlying values for which an enum is defined let definedVals<'a, 'b when 'a : enum<'b>> = System.Enum.GetValues(typeof<'a>) |> Seq.cast<'a> |> Seq.map (LanguagePrimitives.EnumToValue) let ints = definedVals<System.ConsoleColor,_> 
+3
source

All Articles