<commit_before># Key Path Expressions as Functions

* Proposal: [SE-0249](0249-key-path-literal-function-expressions.md)
* Authors: [<NAME>](https://github.com/stephencelis), [<NAME>](https://github.com/gregomni)
* Review Manager: [<NAME>](https://github.com/airspeedswift)
* Status: **Implemented (Swift 5.2)**
* Implementation: [apple/swift#19448](https://github.com/apple/swift/pull/19448)

## Introduction

This proposal introduces the ability to use the key path expression `\Root.value` wherever functions of `(Root) -> Value` are allowed.

Swift-evolution thread: [Key Path Expressions as Functions](https://forums.swift.org/t/key-path-expressions-as-functions/19587)

Previous discussions:

- [Allow key path literal syntax in expressions expecting function type](https://forums.swift.org/t/allow-key-path-literal-syntax-in-expressions-expecting-function-type/16453)
- [Key path getter promotion](https://forums.swift.org/t/key-path-getter-promotion/11185)
- [[Pitch] KeyPath based map, flatMap, filter](https://forums.swift.org/t/pitch-keypath-based-map-flatmap-filter/6266)

## Motivation

One-off closures that traverse from a root type to a value are common in Swift. Consider the following `User` struct:

```swift
struct User {
    let email: String
    let isAdmin: Bool
}<commit_msg>[SE-0249] Update the implementation link<commit_after># Key Path Expressions as Functions

* Proposal: [SE-0249](0249-key-path-literal-function-expressions.md)
* Authors: [<NAME>](https://github.com/stephencelis), [<NAME>](https://github.com/gregomni)
* Review Manager: [<NAME>](https://github.com/airspeedswift)
* Status: **Implemented (Swift 5.2)**
* Implementation: [apple/swift#26054](https://github.com/apple/swift/pull/26054)

## Introduction

This proposal introduces the ability to use the key path expression `\Root.value` wherever functions of `(Root) -> Value` are allowed.

Swift-evolution thread: [Key Path Expressions as Functions](https://forums.swift.org/t/key-path-expressions-as-functions/19587)

Previous discussions:

- [Allow key path literal syntax in expressions expecting function type](https://forums.swift.org/t/allow-key-path-literal-syntax-in-expressions-expecting-function-type/16453)
- [Key path getter promotion](https://forums.swift.org/t/key-path-getter-promotion/11185)
- [[Pitch] KeyPath based map, flatMap, filter](https://forums.swift.org/t/pitch-keypath-based-map-flatmap-filter/6266)

## Motivation

One-off closures that traverse from a root type to a value are common in Swift. Consider the following `User` struct:

```swift
struct User {
    let email: String
    let isAdmin: Bool
}
{'fraction_non_alphanumeric': 0.14285714285714285, 'fraction_numerical': 0.03123809523809524, 'mean_word_length': 5.022935779816514, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2887966', 'n_tokens_mistral': 910, 'n_tokens_neox': 809, 'n_words': 202}