Is it possible to do pattern matching on variables instead of constant values:
# let x = 2 in let y = 5 in match 2 with | x -> \"foo\" | y -> \"bar\" |
A "when" guard is what you're looking for here:
let x = 2 in let y = 5 in match 2 with | x' when x' = x -> "foo" | y' when y' = y -> "baz" | _ -> "baz" ;;
...though I'm not sure why you'd ever want to match with a constant.