I have noticed I cannot create two active patterns with the same options, but I can have two with similar ones without any warning:
let (|A|B|C|) c =
if (c = 'a') then A
else if (c = 'b') then B
else C
let (|A|B|D|) c =
if (c = '1') then A
else if (c = '2') then B
else D
So when matching this way:
let check myvar =
match myvar with
| A -> printf "match A\n"
| n -> printf "match other %A\n" n
This happens:
check 'x' // match other 'x'
check 'a' // match other 'a' !!
check '1' // match A
I am a bit concerned of overwriting existing active pattern options inadvertently, for example in situations where the same word can appear in different patterns because different semantic contexts, like (|Direct|Indirect|)
(route) and (|Alternating|Direct|)
(current).
How can I avoid this situations?