In the following code:
type color = [`Red | `Blue | `Green | `Black | `White]
let color_index c = match c with
| `Red -> 1
| `Blue -> 2
| `Green -> 3
| `Black -> 4
| `White -> 5
type value = [`Red | `Blue | `Green | `Missing]
type state = Color of int | Missing
let state_of_value v = match v with
| `Red -> Color (color_index `Red)
| `Blue -> Color (color_index `Blue)
| `Green -> Color (color_index `Green)
| `Missing -> Missing
is there any way to write the last function as
let state_of_value v = match v with
| `Red | `Blue | `Green -> ?????
| `Missing -> Missing
martin