-
Notifications
You must be signed in to change notification settings - Fork 451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add common extensions for option #2397
Conversation
|
||
inline fun <B, C, D> zip( | ||
b: Option<B>, | ||
c: Option<C>, | ||
map: (A, B, C) -> D | ||
): Option<D> = | ||
zip(b, c, Some.unit, Some.unit, Some.unit, Some.unit, Some.unit, Some.unit, Some.unit) { b, c, d, _, _, _, _, _, _, _ -> map(b, c, d) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like these changes are just new formatting? I don't have a preference but just thought I'd mention it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, it's only reformatting. it kept doing that everytime i did a reformat code through intellij. My intellij seems to have picked up everything in editor config but the line length settings..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks great, @myuwono! Thanks so much for taking care of this and making it consistent. I've noticed we added the bifunctor methods like bitraverse, but they have no test associated; perhaps adding a couple more tests for those will help as we are about to turn codecov. Someone else would eventually have to add it.
Thanks again!
thanks @raulraja yeah indeed it did look like those codes were added without tests. I've taken care of those as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @myuwono for this contribution 😍!! And congratz on your first contribution to the repo 👏 👏 👏 🎉 🎉 🎉
A couple of nits to implement traverse
for Option
directly to shave off some unnecessary allocations.
arrow-libs/core/arrow-core/src/main/kotlin/arrow/core/Iterable.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/main/kotlin/arrow/core/NonEmptyList.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/main/kotlin/arrow/core/Sequence.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
@nomisRev I've used direct implementation for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks @myuwono for the contribution!! 👏 👏 👏 And congrats & welcome with your first contribution in this repo 😁 🎉 🎉 🎉
Whoops seems like i forgot to format Iterable.kt before the previous commit. @nomisRev That's fixed. |
Welcome to this repository as well @myuwono and thanks!! 🎉 |
In this PR
Option<A>.pairLeft(l: L): Option<Pair<L, A>>
andOption<A>.pairRight(r: R): Option<Pair<A, R>>
List<Option<A>>.flattenOption(): List<A>
Map<K, Option<V>>.filterOption(): Map<K, V>
Sequence<Option<A>>.filterOption(): Sequence<A>
F<A>.traverseOption(f: (A) -> Option<B>): Option<F<B>>
andF<Option<T>>.sequence(): Option<F<T>>
for either, option, validated, ior, lists, nonemptylists, sequence, and maps.fixes #2374