GodefroyClair opened a new issue, #25807: URL: https://github.com/apache/beam/issues/25807
Maybe I'm not asking at the right place but I am quite surprised about the way `Flatten()` and `FlatMap()` are implemented in Python. Normally, in functional progamming (Haskell, Scala...), FlatMap() should be the same as composing `Flatten()` and `Map()`. But in Apache Beam, Flatten() is using _iterable of PCollections_ while FlatMap() is working with _PCollection of Iterables_. ``` Flatten:: Iterable[PCollections[A]] -> PCollection[A] Map:: (PCollection[A], (A-> B)) -> PCollection[B] FlatMap:: (PCollection[Iterable[A]], (A->B)) -> [A] ``` So my question is is there another Flatten with this signature : anotherFlatten:: PCollection[Iterable[A]] -> PCollection[A] One of the reason this would be useful, is that when you just want to use `Flatten` a `PCollection` of `iterable` you have to use `FlatMap()`with an identity function (for example to use empty list as an alternative to the [Maybe/Optional Monad](https://blog.ploeh.dk/2022/04/25/the-maybe-monad/) Pattern) So instead of writing: `FlatMap(lambda e: e)` I would like to have a function `anotherFlatten()` Plus this is not helping when you are trying to teach functional programming with Apache Beam to Pythonist... it kinds of break the intuition about FlatMap. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
