This is very appealing. Having worked with this feature in Ruby, I can confirm that although passing keypaths to map and friends is a minor ergonomic improvement, it pays dividends that justify the weight.
The operator alternative is appealing to me; I’ve liked it ever since @SusanCheng described it here.
I would prefer the generality of either of these approaches to method-specific overloads.
Considering whether to allow the language to do the automatic keypath → closure promotion, I wonder:
- What kinds of type errors would this obscure? Are there places where developer intent would not match the keypath → closure promotion, and the lack of a compiler error would obscure a mistake? (I am looking here for specific, realistic scenarios.)
- Are there any places where this creates type inference ambiguity, or especially confusing error messages? Or is it essentially a no-burden addition to the type system?