SE-0222: Lazy compactMap Sequence

I think this proposal is plugging and important performance sensitive hole in the lazy system, fully in line with its current implementation.

To the concern about raising complexity of the lazy system has been raised above, I can say that after having played quite extensively with tangentially related lazy sequences that are currently unsupported in standard library, due to historically ad-hoc approach to its implementation, the lazy subsystem is the only way to get a well performing code. Its current implementation is leaking a ton of implementation details (there is sprawling plethora of concrete return types, that aren't useful outside of their super-narrow role of opaque container conforming to the Sequence/Collection protocols), but until we have much more powerful type system, we have to live with that. This proposal even helps to curb this a little bit by collapsing a chain of lazy calls into single return type that doesn't propagate the nested generics too much.

Therefore, in my opinion, this proposal is an important stopgap measure to get more performant sequences and collections in the standard library. :+1:

6 Likes