flatMap #15
Replies: 2 comments 3 replies
-
Hi @JaapWijnen! We have a discussion about this in our episodes on In short, types with func map<NewValue>(_ transform: (Value) -> NewValue) -> MyType<NewValue> {
self.flatMap { /* return new MyType by transforming self.value and bundling it up */ }
}
func zip<A, B>(_ a: MyType<A>, _ b: MyType<B>) -> MyType<(A, B)> {
a.flatMap { a in b.flatMap { b in /* return new MyType by bundling up 'a' and 'b' */ } }
} However, this
Because of this I'm going to convert this to a discussion, but maybe we should mention the absence of |
Beta Was this translation helpful? Give feedback.
-
@stephencelis Was still thinking about this. Even with your explanation (and rewatching the episode you mentioned) I don't fully understand why the new zip (not derived from flatmap) wouldn't be able to live side by side with flatMap. Would you mind elaborating a bit more? Allowing flatMap as API doesn't force us to use a zip function based on flatMap does it? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Any specific reason methods like flatMap and sequence (from the pointfree.co episodes)aren't included in the package?
Beta Was this translation helpful? Give feedback.
All reactions