Extending the Result Type - More Expressive Error Handling

In the thread about extracting enum payloads I proposed to extend the syntax of anonymous functions with pattern matching abilities (copying the full text here to keep the syntax highlighting intact):

I‘d like to propose a different solution: what about extending the syntax of anonymous functions to enable pattern matching on its arguments, i.e.

{ case .foo(let val) in val }

This would pattern match the argument and in the matching case return the result of the function wrapped in .some (i.e. .some(val)) and in the non matching case return nil.

This would keep all the safety and power of pattern matching, including elegant handling of multiple parameters where I might only be interested in some of them and nestings, e.g.

{ case .foo(_, .baz(let x, _), let y) in x * y }

-Thorsten