If you want to express the second pat
should be equal to the matched value against the first pat
in your code, your code is wrong. It must be:
let func = function pat ->
function
| pat' when pat = pat' -> x
| b -> y
Pattern variables introduce new fresh variables and cannot refer to values bound to variables with the same name.