I'm ready for their follow up product.
data FooResult = Number | Error
def foo(n: Number): FooResult = ...
foo(42) match {
case n: Number => print(n + 1)
case e: Error => // handle error case
}
This gets you very far most of the time. If the tag overhead matters (which should largely only matter in a hot loop), then try to refactor so that the hot loop doesn't error out.