F# type constraint with Enum type
问题 I would like to write an F# function that takes a generic enum value and, let's say, doubles its underlying integer value. Fortunately, there's a built-in function called int that converts an enum to an integer, so this should be easy, right? Here's my first attempt: let doubler (value : 't when 't : enum<int>) = 2 * (int value) Sadly, this results in the following compiler messages: Program.fs(2,10): warning FS0064: This construct causes code to be less generic than indicated by the type