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

CU-fb50p3 - Clean up Traverse API #2310

Merged
merged 16 commits into from Mar 11, 2021
Merged

CU-fb50p3 - Clean up Traverse API #2310

merged 16 commits into from Mar 11, 2021

Conversation

danimontoya
Copy link
Contributor

@danimontoya danimontoya commented Mar 8, 2021

Fixes https://app.clickup.com/t/fb50p3

Clean up Traverse API:

  • flatTraverse
  • flatTraverseEither
  • flatTraverseValidated
  • travserse_
  • travserEither_
  • traverseValidated_
  • sequence_
  • sequenceEither_
  • sequenceValidated_
  • traverseFilter
  • traverseFilterEither

 - flatTraverse
 - flatTraverseEither
 - flatTraverseValidated
 - travserse_
 - travserEither_
 - traverseValidated_
 - sequence_
 - sequenceEither_
 - sequenceValidated_
@franciscodr
Copy link
Collaborator

Task linked: CU-fb50p3 Clean up Traverse API

…averseFilter, traverseFilterEither, traverseFilterValidated, traverseFilterIsInstance, traverseFilterIsInstanceEither, traverseFilterIsInstanceValidated
@danimontoya danimontoya marked this pull request as ready for review March 9, 2021 09:07
Copy link
Member

@nomisRev nomisRev left a 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.

Comment on lines 835 to 845
@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() })
Copy link
Member

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

Comment on lines 940 to 950
@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)
Copy link
Member

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

Comment on lines 988 to 999
@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) }

Copy link
Member

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

Comment on lines 24 to 28
@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 } })
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem

@@ -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)
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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)
Copy link
Member

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.

Copy link
Member

@nomisRev nomisRev left a 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 👏 👏

Copy link
Member

@raulraja raulraja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @danimontoya !

@nomisRev nomisRev merged commit c04cdb5 into master Mar 11, 2021
@nomisRev nomisRev deleted the dm-cleanup-traverse branch March 11, 2021 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants