Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Tino Heth via swift-evolution
> Am 16.11.2017 um 17:02 schrieb BJ Homer via swift-evolution > : > > The filterMap operation runs a map that can filter stuff out. So if map can filter, what’s your opinion on calling the operation mapmap? ;-)___ swift-evolution mailing list swift-ev

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Lance Parker via swift-evolution
I dislike `mapSome` because, to me, it implies it will only pass the non-nil values of the sequence to the transformation closure. `compactMap` isn’t an intuitive name, but I could get used to it. The thing I like about it is it could be paired with a `compacted` method that removes nils from

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread David Waite via swift-evolution
> On Nov 15, 2017, at 7:16 PM, Greg Parker via swift-evolution > wrote: > >> >> On Nov 15, 2017, at 5:53 PM, John McCall > > wrote: >> >>> On Nov 15, 2017, at 7:36 PM, Greg Parker via swift-evolution >>> mailto:swift-evolution@swift.org>> wrote: >>> >>> "compac

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Dave DeLong via swift-evolution
I agree with Gwendal’s reasoning about the introduction of the term “compact” into the API nomenclature. Removing non-existent values is qualitatively different than selecting a subset of a sequence based on properties of the contained values, and thus merits different terminology. Put a differe

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Kevin Nattinger via swift-evolution
As far as the Sequence overloads: I really, really think we should go a step beyond renaming and separate the functions into the underlying operations. FlatMap has three separate and orthogonal effects, so it should be split into three functions—flatten, map, and dropNil. Map already exists, obv

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Brandon Williams via swift-evolution
I’ll put my vote in for `filterMap`! I’d like to call out some fun properties and generalizations that `filterMap` has that might give a little more credence to why it should be called this. There is a very natural way of bridging the worlds of optionals and booleans. In fact, considering that

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Erica Sadun via swift-evolution
I like `mapSome`: * `mapSome` uses conventional Swift terminology. * It makes the outcome and expectations clear. * As a bonus, it combines the English meaning of "some" ("map across some of these items", as in creating a filtered result) and the `Optional` case name. In response to John's "

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread BJ Homer via swift-evolution
> On Nov 15, 2017, at 11:07 PM, Gwendal Roué via swift-evolution > wrote: > > >> Le 16 nov. 2017 à 06:29, Matt Gallagher via swift-evolution >> mailto:swift-evolution@swift.org>> a écrit : >> >> My opinion is that filterMap is the right choice of name. >> >> I'm completely biased, given tha

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread BJ Homer via swift-evolution
> On Nov 16, 2017, at 2:52 AM, Gwendal Roué via swift-evolution > wrote: > >> The optional itself will stand for the boolean needed by the filtering >> operation. > > What I meant here is that "filterMap" can only click in a developer's mind if > the the developer uses Optional as a Bool. Wh

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread BJ Homer via swift-evolution
mapSome is easy to misunderstand; the naïve reading suggests that only some of the source elements will be mapped, and doesn’t specify which ones. Even if the reader correctly intuits that it refers to Optional.some, they may incorrectly believe that it only maps the non-nil elements in the sour

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Shawn Erickson via swift-evolution
I so far am most in favor of mapSome out of the names I have seen followed by mapAndUnwrap (however the later is growing on me). To me the most important thing is when reading code that it is quick to understand generally what is going on followed by discoverability of a new comer. I think both o

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Benjamin G via swift-evolution
I like mapAndUnwrap , but just for the record I'd like to add "mapThenUnwrap" I'm not a native english, but i think "and" doesn't convey as much meaning relative to the order of the operation as "then". As a sidenote, if we go this road I think flatMap should also be the object of a renaming prop

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Jean-Daniel via swift-evolution
> > Here's a variety of possible new names, in descending order of personal > preference: > > mapUnwrappingSome > mapAndUnwrap // Thanks Nevin, this is surprisingly clear. > mapUnwrapSome > mapUnwrapIfSome > mapSome // For these last three, it's unclear when nil elements are >

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Gwendal Roué via swift-evolution
> Le 16 nov. 2017 à 11:06, Brent Royal-Gordon via swift-evolution > a écrit : > >> On Nov 15, 2017, at 4:36 PM, Greg Parker via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >> "compactMap" is okay if "compact" is added. Is "compact" a common enough >> operation in practice

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Brent Royal-Gordon via swift-evolution
> On Nov 15, 2017, at 4:36 PM, Greg Parker via swift-evolution > wrote: > > "compactMap" is okay if "compact" is added. Is "compact" a common enough > operation in practice to pull its own weight? Lines containing code like `flatMap { $0 }`—which could be compacting optionals or flattening ne

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Gwendal Roué via swift-evolution
> The optional itself will stand for the boolean needed by the filtering > operation. What I meant here is that "filterMap" can only click in a developer's mind if the the developer uses Optional as a Bool. When the closure returns nil, that nil stands for false in the filtering operation. Whe

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Gwendal Roué via swift-evolution
Yes, you are right. I was too fast. I've been thinking why filterMap has such a traction in the community, despite the fact that this precise "filter" is a tiny subset of the "filter" generally used by the language. I think "filterMap" clicks well in many readers because of this trend of thoug

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-16 Thread Anders Ha via swift-evolution
It does not use `Optional`, but it is semantically equivalent to `filterMap` in CwlSignal and ReactiveSwift, and the `filterMap` proposed for `Sequence` (but in the time domain instead). Regards, Anders > On 16 Nov 2017, at 2:07 PM, Gwendal Roué via swift-evolution > wrote: > > >> Le 16

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Gwendal Roué via swift-evolution
> Le 16 nov. 2017 à 06:29, Matt Gallagher via swift-evolution > a écrit : > > My opinion is that filterMap is the right choice of name. > > I'm completely biased, given that I already have a Swift library that uses > filterMap, in exactly this context, for a Reactive Programming library: > >

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Gwendal Roué via swift-evolution
> Le 16 nov. 2017 à 06:29, Matt Gallagher via swift-evolution > a écrit : > > On the topic of a method that "compacts" without also mapping... I think this > encourages poor designs that should be using lazy transformations instead of > aggregate processing. There is almost always a way aroun

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Matt Gallagher via swift-evolution
My opinion is that filterMap is the right choice of name. I'm completely biased, given that I already have a Swift library that uses filterMap, in exactly this context, for a Reactive Programming library: https://github.com/mattgallagher/CwlSignal/blob/22f1d47895896d7b55bc59a4ee5394071f

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Gwendal Roué via swift-evolution
Hello, I cast my vote for compactMap. And I wish for another proposal for the plain non-mutating method `compacted`. Some say that compact has no precedent in Swift, and is ambiguous. "Compact" has no precedent because it names an operation which had no name yet: filtering out nils. Is is only

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Kevin Ballard via swift-evolution
On Wed, Nov 15, 2017, at 12:55 PM, John McCall via swift-evolution wrote:> Hello, Swift Community! > > The initial review of "SE-0187: Introduce Sequence.filterMap(_:)" > ran through yesterday, November 14th, 2017. The proposal is > available here:> >> https://github.com/apple/swift-evolution/b

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Dylan Brown via swift-evolution
I'll argue in favor of names which include the term "some". "The Optional type is an enumeration with two cases. Optional.none is equivalent to the nil literal. Optional.some(Wrapped) stores a wrapped value." (https://developer.apple.com/documentation/swift/optional) let things = ["apple", nil, "

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Jon Shier via swift-evolution
Given the existence of filter already, I submit that filterMap is somewhat overloaded and users would expect that, like flatMap, it would map over all elements and then filter based on some predicate. While that’s awkward to express and likely isn’t useful enough to be in the standard li

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread John McCall via swift-evolution
> On Nov 15, 2017, at 9:16 PM, Greg Parker wrote: > > >> On Nov 15, 2017, at 5:53 PM, John McCall > > wrote: >> >>> On Nov 15, 2017, at 7:36 PM, Greg Parker via swift-evolution >>> mailto:swift-evolution@swift.org>> wrote: >>> On Nov 15, 2017, at 2:31 PM, BJ H

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Nevin Brackett-Rozinsky via swift-evolution
On Wed, Nov 15, 2017 at 8:05 PM, Wallacy via swift-evolution < swift-evolution@swift.org> wrote: > “unwrappingMap”(or some variations using unwrap). > I’d like to propose “mapAndUnwrap”. It does what it says on the tin: map a sequence (into an optional type), then unwrap the values which exist.

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Greg Parker via swift-evolution
> On Nov 15, 2017, at 5:53 PM, John McCall wrote: > >> On Nov 15, 2017, at 7:36 PM, Greg Parker via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >>> On Nov 15, 2017, at 2:31 PM, BJ Homer via swift-evolution >>> mailto:swift-evolution@swift.org>> wrote: >>> On Nov 15,

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread John McCall via swift-evolution
> On Nov 15, 2017, at 7:36 PM, Greg Parker via swift-evolution > wrote: > >> >> On Nov 15, 2017, at 2:31 PM, BJ Homer via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >>> On Nov 15, 2017, at 3:05 PM, Tino Heth via swift-evolution >>> mailto:swift-evolution@swift.org>> wro

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Wallacy via swift-evolution
I vote for “mapNonNil”, “mapDroppingNil” or “unwrappingMap”(or some variations using unwrap). It’s not pretty, but does the job! Em qua, 15 de nov de 2017 às 22:36, Greg Parker via swift-evolution < swift-evolution@swift.org> escreveu: > On Nov 15, 2017, at 2:31 PM, BJ Homer via swift-evolutio

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Jon Shier via swift-evolution
Having watched this discussion without much opinion before, I’ve found the argument about the meaning of map in a functional context to be somewhat convincing. While Swift isn’t a pure functional language, I think having the concept of a `map` generally mean a 1:1 mapping between input a

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Greg Parker via swift-evolution
> On Nov 15, 2017, at 2:31 PM, BJ Homer via swift-evolution > wrote: > >> On Nov 15, 2017, at 3:05 PM, Tino Heth via swift-evolution >> mailto:swift-evolution@swift.org>> wrote: >> >> Odd… exactly that is the reason why I think filterMap is the worst choice: >> >> Both are established terms

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Hugo Hennies via swift-evolution
I'd like to show my support for mapSome. It's clear, concise and to the point. It's the best name from all the alternatives IMHO > On Nov 15, 2017, at 7:15 PM, Ben Cohen via swift-evolution > wrote: > > I continue to favour mapSome, since it’s both literally and figuratively what > it does, b

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread BJ Homer via swift-evolution
> On Nov 15, 2017, at 3:05 PM, Tino Heth via swift-evolution > wrote: > > Odd… exactly that is the reason why I think filterMap is the worst choice: > > Both are established terms of art, but one has a meaning that doesn’t fit to > the operation. > Applying filter can remove elements, but it

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Tino Heth via swift-evolution
> I’m happy that the rename was accepted. I’d like to support renaming it to > filterMap because it uses two terms of art already pre-existing and > understood by the Swift community Odd… exactly that is the reason why I think filterMap is the worst choice: Both are established terms of art, but

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Stephen Celis via swift-evolution
> On Nov 15, 2017, at 4:15 PM, David Hart via swift-evolution > wrote: > > I’m very much against a term like compactMap because it uses the term compact > which has no precedence in Swift’s Standard Library. I don’t really care what the name ends up being (as long as it’s not “flatMap”), but

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread David Hart via swift-evolution
I understand the sentiment, but the language has so much sugar over Optional that I wouldn’t be surprised if even seasoned developers didn't know the name of Optional’s cases. > On 15 Nov 2017, at 22:15, Ben Cohen via swift-evolution > wrote: > > I continue to favour mapSome, since it’s both

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread David Hart via swift-evolution
> On 15 Nov 2017, at 21:55, John McCall via swift-evolution > wrote: > > Hello, Swift Community! > > The initial review of "SE-0187: Introduce Sequence.filterMap(_:)" ran through > yesterday, November 14th, 2017. The proposal is available here: > > https://github.com/apple/swift-evolution/

Re: [swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread Ben Cohen via swift-evolution
I continue to favour mapSome, since it’s both literally and figuratively what it does, but appreciate that exposing the name of the Optional.some case isn’t to everyone’s taste. > On Nov 15, 2017, at 12:55 PM, John McCall via swift-evolution > wrote: > > Hello, Swift Community! > > The initi

[swift-evolution] [Accepted and Focused Re-review] SE-0187: Introduce Sequence.filterMap(_:)

2017-11-15 Thread John McCall via swift-evolution
Hello, Swift Community! The initial review of "SE-0187: Introduce Sequence.filterMap(_:)" ran through yesterday, November 14th, 2017. The proposal is available here: https://github.com/apple/swift-evolution/blob/master/proposals/0187-introduce-filtermap.md