I have a type with constructors which take many arguments. When pattern matching on a constructor of this type, I would like to forward the arguments as a pack (maybe a tuple?), without having to retype them all.
This is code I would like to write:
type foo_t = | FromInt of int * int | FromFloat of floatlet sum_pair (a, b) = a + b;;let f foo = match foo with | FromInt (a, b) as pair -> sum_pair pair | FromFloat _ -> 0;;
The problem here is that pair
is typed as foo_t
instead of int * int
. But sum_pair
should expect a pair of ints and not a foo_t
.