-
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
rename traverseX and sequenceX for Iterable #2692
Conversation
For parTraverse I will provide an example repo and leave a comment https://youtrack.jetbrains.com/issue/KT-49658 where it is failing |
The issue you linked @i-walker isn't the ticket what is causing issue with
If we would rename We should create a ticket for this deprecation, and work when the above issue in Kotlin is fixed. |
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Iterable.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Iterable.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Iterable.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Iterable.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Iterable.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Iterable.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Iterable.kt
Outdated
Show resolved
Hide resolved
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Iterable.kt
Outdated
Show resolved
Hide resolved
|
||
@OptIn(ExperimentalTypeInference::class) | ||
@OverloadResolutionByLambdaReturnType | ||
public inline fun <A, B> Iterable<A>.traverse(f: (A) -> B?): List<B>? { |
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.
Curious that this doesn't conflict with the other traverse
functions 🤔
This seems like one of those signatures that breaks all other functions 😅
What happens in the case of:
fun either(i: Int): Either<String, Int>? = null
val x: ??? = listOf(1, 2, 3).traverse { either(i) }
I guess ???
here is List<Either<String, Int>>?
, and to turn it into Either<String, List<Int>>?
we'd need to chain it with ?.sequence()
. That'd be pretty cool if that works like that out of the box.
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.
Yes this one would be List<Either<String, Int>>? I can set up a small example test
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Iterable.kt
Outdated
Show resolved
Hide resolved
These are some of the coolest functions in the lib, would it possible to save them in some form? 🥺 |
…erable.kt Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
…erable.kt Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
…erable.kt Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
…erable.kt Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
…erable.kt Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
…erable.kt Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
…erable.kt Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
…erable.kt Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
…erable.kt Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
@pakoito not sure what you mean? The only "big" change that is happening is that we're changing the signature from |
Gotcha! |
Co-authored-by: Simon Vergauwen <nomisRev@users.noreply.github.com>
arrow-libs/core/arrow-core/src/commonTest/kotlin/arrow/core/IterableTest.kt
Outdated
Show resolved
Hide resolved
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 great to me @i-walker! Awesome clean-up. Now all methods are simply traverse
and sequence
and the compiler automatically picks the correct one 🥳
} | ||
} | ||
|
||
"sequence Either traverse Nullable interoperate - and proof map + sequence equality with traverse" { |
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.
Thanks, @i-walker! This is pretty cool that it works out of the box!
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.
thanks @i-walker
for parTraverse I'll add another PR since this needs a bit of investigating