Does the F # pattern matching of an instance of a discriminated party member support criteria other than the identifier pattern ?
For example, imagine that I want to combine a basic data form, and I want to consider something with the form int * int, regardless of how the DU classifies the value. Is an
Here is how I would do it now:
type ExampleDU =
| BinaryCase1 of x:int * y:int
| BinaryCase2 of x:int * y:int
| UnaryCase1 of x:int
let underlyingValue = (1,2)
let asCase1 = BinaryCase1 underlyingValue
let asCase2 = BinaryCase2 underlyingValue
let shapeName =
match asCase1 with
| BinaryCase1 (x,y) | BinaryCase2 (x,y) -> "pair"
| _ -> "atom"
I would like something closer to the following:
let shapeName =
match asCase1 with
| (x,y) -> "pair"
| _ -> "atom"
Is there some similar expressive syntax that is currently supported in F # or am I stuck in explicitly defining all cases?
Note. I know that I could figure out how to find the information I want with a reflection, but that doesn't interest me.