IMO this is the biggest thing available to modern languages that Java is missing. I would absolutely love to see this, particularly pattern decomposition. I wonder if you could do it without something analogous to Scala's sealed classes though--you really want your type checker to be able to assert every match has considered every branch (without having to specify a "default" everywhere). That means you need to be able to mark classes as not-dynamically-extendible, so the type checker has the full set of subtypes available.

Edit: Just got to the bottom of the article. Looks like sealed hierarchies is exactly what they explore.

I retrofitted F# style "discriminated unions" (which are basically sealed heirarchies) into C# by creating a series of generic types `OneOf` which can hold exactly one value,

Each type has a `.Match` and `.Switch` methods, in to which you have to pass lambdas to handle each case `.Match(Func`.

I don't know if this would work in Java, given the generic type erasure, but it might...

1. https://github.com/mcintyre321/OneOf