I have run into this case a few times, wonder if there is a way to do the following better:
public type SubType = {
#one;
#two;
};
public type SuperType = {
#three;
};
switch (superType) {
case (#three) processThree();
case (#two) processSubType(#two);
case (#one) processSubType(#one);
};
public func processSubType(subType : SubType) {
...
};
It gets tedious to list out all the subtypes that all do one thing. I want to just make one call like:
switch (superType) {
case (#three) processThree();
// Remaining cases have to be the subtype
case (subType) processSubType(subType);
};
Or maybe a type pattern check like:
switch (superType) {
case (#three) processThree();
case (subType is SubType s) processSubType(s);
};
Any alternatives?