-
Notifications
You must be signed in to change notification settings - Fork 449
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
Deprecate Iterable#unzip in favor of stdlib method #3352
Deprecate Iterable#unzip in favor of stdlib method #3352
Conversation
arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Iterable.kt
Outdated
Show resolved
Hide resolved
@Deprecated( | ||
"Unzip is being deprecated in favor of the standard library version.\n$NicheAPI", | ||
ReplaceWith("unzip()", "kotlin.collections.unzip") | ||
) | ||
public fun <A, B> Iterable<Pair<A, B>>.unzip(): Pair<List<A>, List<B>> = | ||
fold(emptyList<A>() to emptyList()) { (l, r), x -> |
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.
This should just delegate to stdlib unzip
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.
In addition to the deprecation you mean? Changed this in e81b318, not sure if there's a better way to call the standard library method than using an import alias though (to avoid confusion with the other unzip methods in the file).
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, that's exactly what I intended! I think an import alias is just the right approach here. I wonder how the ReplaceWith
will function because of the name discrepancy though. kotlin.collections.*
is a default import, and so perhaps we could just deprecate this with HIDDEN
level. I'd rather wait though on another reviewer's opinion as to whether HIDDEN
is the right approach here or not.
Perhaps the implementation for |
From what I can tell the other unzip methods have no equivalent in the stdlib. NonEmptyList is of course covered by the Iterable#unzip, but still has a use-case because of returning a pair of NonEmptyLists rather than a pair of regular Lists.
1d8453d
to
321426a
Compare
Added this in 484e3df. I can't run all the tests locally for some reason (getting some random failures even with the main branch), but I think all the relevant tests are passing. |
The PR checks will take care of trying the tests, don't worry! |
Might be KMP setup, like @kyay10 said, not important since CI verifies everything but if you run into this again in the future KDoctor is a great tool to help you setup your KMP development environment. |
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.
LGTM. Thank you @terminalnode! 🙌
From what I can tell the other unzip methods have no equivalent in the stdlib.
NonEmptyList is of course covered by the Iterable#unzip, but still has a use-case because of returning a pair of NonEmptyLists rather than a pair of regular Lists.
This is Iterable#unzip in kotlin 1.9.22: