I accept the motivation for this change, although I would mention that:
- in 2.5 years on a ~200k lines of Swift project
- we've seen a plenty of instances of `flatMap` used where `map` would have
been sufficient, but
- we've never burned time on tracking down the sort of compiler issue
described by the author in the Motivation. As I say, the argument is fair,
but I am questioning how frequently this problem occurs.

I can't speak to the previous attempts to solve this problem, but I'd add
my voice to anyone advocating solving this by having a compiler warning
when `flatMap` is used redundantly(?).

If this proposal were to be accepted, I'd also question the choice of
`filterMap` as a name. This name is presumably shorthand for
`filterNonesAndMap`, which conveniently ignores the following:
- `flatMap` may be used on a sequence-of-sequences to flatten our to a
single-dimensional sequence.
- `flatMap` may be used on other 'box' types, e.g. on an optional: `Optional
<String>("foo").flatMap { .some($0 + "bar") }` or on the common `Result`
type.

Any re-naming of one `flatMap` should take these other uses into account,
as they share conceptual details.

Thanks,

Sam
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to