# Pitch: Support for map and flatMap with smart key paths

**URL:** <https://forums.swift.org/t/pitch-support-for-map-and-flatmap-with-smart-key-paths/6073>\
**Category:** Pitches\
**Created:** [June 7, 2017, 5:35pm UTC](https://forums.swift.org/t/pitch-support-for-map-and-flatmap-with-smart-key-paths/6073 "2017-06-07T17:35:49Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![zoul](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/zoul/32/9559_2.png) [@zoul](https://forums.swift.org/u/zoul)\
**Post date:** [September 19, 2018, 6:37am UTC](https://forums.swift.org/t/pitch-support-for-map-and-flatmap-with-smart-key-paths/6073/22 "2018-09-19T06:37:27Z")

</div>

I think what’s keeping this from getting implemented is that key paths should really behave more like functions (ie. `KeyPath<T, U>` should be a subtype of `T -> U` or something like that), and then we would get mapping for free. So the last time this came up, the conclusion was that adding a separate overload of `map` and `flatMap` for keypaths would be pure sugar and we should come up with a more general solution.

Ah, found it, quoting @Joe_Groff [here](https://forums.swift.org/t/key-path-getter-promotion/11185/5):

> Instead of introducing a subtype relationship, we could (and should) extend the key path literal syntax to be valid in function type context, which I think covers the most common use case for this conversion of passing a literal property reference as an argument to map and friends.

---

_[View the full topic](https://forums.swift.org/t/pitch-support-for-map-and-flatmap-with-smart-key-paths/6073)._
