Skip to content
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

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import arrow.typeclasses.SemigroupDeprecation
import arrow.typeclasses.combine
import kotlin.experimental.ExperimentalTypeInference
import kotlin.jvm.JvmName
import kotlin.collections.unzip as stdlibUnzip

public inline fun <B, C, D, E> Iterable<B>.zip(
c: Iterable<C>,
Expand Down Expand Up @@ -844,10 +845,12 @@ public fun <A> Iterable<A>.salign(
* <!--- KNIT example-iterable-11.kt -->
* <!--- TEST lines.isEmpty() -->
*/
@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 ->
l + x.first to r + x.second
}
stdlibUnzip()

/**
* after applying the given function unzip the resulting structure into its elements.
Expand All @@ -867,8 +870,12 @@ public fun <A, B> Iterable<Pair<A, B>>.unzip(): Pair<List<A>, List<B>> =
* <!--- KNIT example-iterable-12.kt -->
* <!--- TEST lines.isEmpty() -->
*/
@Deprecated(
"Unzip is being deprecated in favor of the standard library version.\n$NicheAPI",
ReplaceWith("map(fc).unzip()", "kotlin.collections.unzip")
)
public inline fun <A, B, C> Iterable<C>.unzip(fc: (C) -> Pair<A, B>): Pair<List<A>, List<B>> =
map(fc).unzip()
map(fc).stdlibUnzip()

/**
* splits a union into its component parts.
Expand Down
Loading