-
Notifications
You must be signed in to change notification settings - Fork 448
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
CU-fb50p3 - Clean up Traverse API #2310
Conversation
- flatTraverse - flatTraverseEither - flatTraverseValidated - travserse_ - travserEither_ - traverseValidated_ - sequence_ - sequenceEither_ - sequenceValidated_
Task linked: CU-fb50p3 Clean up Traverse API |
…averseFilter, traverseFilterEither, traverseFilterValidated, traverseFilterIsInstance, traverseFilterIsInstanceEither, traverseFilterIsInstanceValidated
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.
@danimontoya we need to compare with 0.11.0
since most of the methods deprecated here can be removed. They were all added newly on master
only.
@Deprecated(TraverseDeprecation) | ||
inline fun <C> traverse_(fa: (B) -> Iterable<C>): List<Unit> = | ||
fold({ emptyList() }, { fa(it).void() }, { _, b -> fa(b).void() }) | ||
|
||
@Deprecated(TraverseDeprecation) | ||
inline fun <AA, C> traverseEither_(fa: (B) -> Either<AA, C>): Either<AA, Unit> = | ||
fold({ Either.right(Unit) }, { fa(it).void() }, { _, b -> fa(b).void() }) | ||
|
||
@Deprecated(TraverseDeprecation) | ||
inline fun <AA, C> traverseValidated_(fa: (B) -> Validated<AA, C>): Validated<AA, Unit> = | ||
fold({ Valid(Unit) }, { fa(it).void() }, { _, b -> fa(b).void() }) |
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.
These can all be deleted, they didn't exist yet on 0.11.0
@Deprecated(TraverseDeprecation) | ||
fun <A, B> Ior<A, Iterable<B>>.sequence_(): List<Unit> = | ||
traverse_(::identity) | ||
|
||
@Deprecated(TraverseDeprecation) | ||
fun <A, B, C> Ior<A, Either<B, C>>.sequenceEither_(): Either<B, Unit> = | ||
traverseEither_(::identity) | ||
|
||
@Deprecated(TraverseDeprecation) | ||
fun <A, B, C> Ior<A, Validated<B, C>>.sequenceValidated_(): Validated<B, Unit> = | ||
traverseValidated_(::identity) |
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.
These can all be deleted, they didn't exist yet on 0.11.0
@Deprecated(TraverseDeprecation) | ||
inline fun <A, B, C> Ior<A, B>.flatTraverse(SA: Semigroup<A>, f: (B) -> Iterable<Ior<A, C>>): List<Ior<A, C>> = | ||
traverse(f).map { it.flatten(SA) } | ||
|
||
@Deprecated(TraverseDeprecation) | ||
inline fun <A, B, C, E> Ior<A, B>.flatTraverseEither(SA: Semigroup<A>, f: (B) -> Either<E, Ior<A, C>>): Either<E, Ior<A, C>> = | ||
traverseEither(f).map { it.flatten(SA) } | ||
|
||
@Deprecated(TraverseDeprecation) | ||
inline fun <A, B, C, E> Ior<A, B>.flatTraverseValidated(SA: Semigroup<A>, f: (B) -> Validated<E, Ior<A, C>>): Validated<E, Ior<A, C>> = | ||
traverseValidated(f).map { it.flatten(SA) } | ||
|
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.
These can all be deleted, they didn't exist yet on 0.11.0
@Deprecated(TraverseDeprecation) | ||
inline fun <E, A, B> Iterable<A>.flatTraverseEither(f: (A) -> Either<E, Iterable<B>>): Either<E, List<B>> = | ||
foldRight<A, Either<E, List<B>>>(emptyList<B>().right()) { a, acc -> | ||
f(a).ap(acc.map { bs -> { b: Iterable<B> -> b + bs } }) | ||
} |
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.
Idem
…rseValidated_, flatSequenceValidated, sequenceValidated_
@@ -526,11 +527,13 @@ inline fun <E, A, B> NonEmptyList<A>.traverseEither(f: (A) -> Either<E, B>): Eit | |||
f(a).ap(acc.map { bs -> { b: B -> NonEmptyList(b) + bs } }) | |||
} | |||
|
|||
@Deprecated(TraverseDeprecation) |
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.
All of these didn't exist for NonEmptyList
on 0.11.0
so can be removed.
https://github.com/arrow-kt/arrow-core/blob/0.11.0/arrow-core-data/src/main/kotlin/arrow/core/NonEmptyList.kt
@@ -749,18 +743,21 @@ sealed class Option<out A> : OptionOf<A> { | |||
is None -> null | |||
} | |||
|
|||
@Deprecated(TraverseDeprecation) |
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.
@@ -108,11 +109,13 @@ fun <E, A> Sequence<Either<E, Sequence<A>>>.flatSequenceEither(): Either<E, Sequ | |||
fun <E, A> Sequence<Validated<E, Sequence<A>>>.flatSequenceValidated(semigroup: Semigroup<E>): Validated<E, Sequence<A>> = | |||
flatTraverseValidated(semigroup, ::identity) | |||
|
|||
@Deprecated(TraverseDeprecation) |
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.
Idem for these, since this file doesn't exist in 0.11.0 so we can simply remove them all.
@@ -791,6 +792,7 @@ sealed class Validated<out E, out A> : ValidatedOf<E, A> { | |||
inline fun <B> traverse(fa: (A) -> Iterable<B>): List<Validated<E, B>> = | |||
fold({ emptyList() }, { a -> fa(a).map { Valid(it) } }) | |||
|
|||
@Deprecated(TraverseDeprecation) |
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.
Idem for all functions in this file: https://github.com/arrow-kt/arrow-core/blob/0.11.0/arrow-core-data/src/main/kotlin/arrow/core/Validated.kt
@@ -23,11 +24,13 @@ inline fun <K, E, A, B> Map<K, A>.traverseEither(f: (A) -> Either<E, B>): Either | |||
f(a).ap(acc.map { bs: Map<K, B> -> { b: B -> mapOf(k to b) + bs } }) | |||
} | |||
|
|||
@Deprecated(TraverseDeprecation) |
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.
None of these methods existed so can all be removed safely.
# Conflicts: # arrow-libs/core/arrow-core-data/src/main/kotlin/arrow/core/Option.kt
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 @danimontoya for the PR 👏 👏
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 @danimontoya !
Fixes https://app.clickup.com/t/fb50p3
Clean up Traverse API: