Edit: nevermind, I might promote it when it's more generally available.
$v:|[:int, :bool, :double] = 5;
$vi: = v.[:int];
$holds_int: = v.?[:int];
switch v {
.[:int]$i { /std cout << "got int:" << i };
.[:bool] { /std cout << "got bool" };
.[:double]$d { /std cout << "got double: " << d };
};
If a type repeats in the same variant, you would match by index to tell them apart: $v:|[:int, :int]<(.[0] = 5);
switch v {
.[0]$i0 { /std cout << "got first int:" << i0 };
.[1]$i1 { /std cout << "got second int: " << i1 };
};
(I have some ideas to allow named labels instead of numerical indices but that is not yet implemented)