Another issue related to the F # function called "Type Extensions" .
It seems impossible to expand the enumerations in F #. I often use C # Extensions Methods to expand enumerations: adds range checking logic, a method that returns a string representation, etc.
Unfortunately, it seems possible to expand only the discriminated union, but it is impossible to expand simple enumerations :
1. Internal expansion
module CustomEnumModule
type CustomEnum =
| Value1 = 1
| Value2 = 2
type CustomEnum with
| Value3 = 3
Error: 'error FS0010: Unexpected character' | ' in the definition of a member
2. Additional extension
// CustomEnumEx.fs
open CustomEnumModule
type CustomEnum with
member public x.PrintValue() =
printfn "%A" x
Error: "error FS0896: enumerations cannot have members"
, (1) , (2) .NET enums - ( FP-) .
, ?
P.S. F # Spec , , , .