A variant of this syntax and a proof of concept implementation built on top of adt [1] library:
The upstream ADT library has some mypy plugins. Would be great if other type checkers supported something like this out of the box.
This syntax is now supported in the python -> rust transpiler. Test case in this commit:
I also have a version of Richard's benchmark using this syntax transpiled to rust. The generated code doesn't compile yet.
The only thing missing is a plan for some syntax in python that can be mapped to pattern matching as an expression in rust. Please get in touch with me offline if you're interested in discussing it further.
-Arun