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 Either.toValidated() and Either.toValidatedNel() functions #2974

Merged
merged 7 commits into from
Mar 10, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import arrow.core.Either.Companion.resolve
import arrow.core.Either.Left
import arrow.core.Either.Right
import arrow.core.Either.Right.Companion.unit
import arrow.core.computations.ResultEffect.bind
import arrow.core.continuations.Eager
import arrow.core.continuations.EagerEffect
import arrow.core.continuations.Effect
import arrow.core.continuations.Token
import arrow.core.raise.Raise
import arrow.core.raise.either
import arrow.typeclasses.Monoid
Expand Down Expand Up @@ -772,7 +769,7 @@ public typealias EitherNel<E, A> = Either<NonEmptyList<E>, A>
* Option does not require a type parameter with the following functions, but it is specifically used for Either.Left
*/
public sealed class Either<out A, out B> {

/**
* Returns `true` if this is a [Right], `false` otherwise.
* Used only for performance instead of fold.
Expand Down Expand Up @@ -1338,9 +1335,11 @@ public sealed class Either<out A, out B> {
{ "Either.Right($it)" }
)

@Deprecated(ValidatedDeprMsg + "ValidatedNel is being replaced by EitherNel")
public fun toValidatedNel(): ValidatedNel<A, B> =
fold({ Validated.invalidNel(it) }, ::Valid)

@Deprecated(ValidatedDeprMsg + "You can find more details about how to migrate on the Github release page, or the 1.2.0 release post.")
public fun toValidated(): Validated<A, B> =
fold({ it.invalid() }, { it.valid() })

Expand Down Expand Up @@ -2297,7 +2296,7 @@ public operator fun <A : Comparable<A>, B : Comparable<B>> Either<A, B>.compareT
ReplaceWith("Either.zipOrAccumulate({ a, bb -> SGA.run { a.combine(bb) } }, this, b) { a, bb -> SGB.run { a.combine(bb) } }")
)
public fun <A, B> Either<A, B>.combine(SGA: Semigroup<A>, SGB: Semigroup<B>, b: Either<A, B>): Either<A, B> =
Either.zipOrAccumulate({ a, bb -> SGA.run { a.combine(bb) } }, this, b) { a, bb -> SGB.run { a.combine(bb) } }
Either.zipOrAccumulate({ a, bb -> SGA.run { a.combine(bb) } }, this, b) { a, bb -> SGB.run { a.combine(bb) } }
Zordid marked this conversation as resolved.
Show resolved Hide resolved

@Deprecated(
RedundantAPI + "Prefer explicit fold instead",
Expand Down Expand Up @@ -2664,7 +2663,7 @@ public fun <E> E.leftNel(): EitherNel<E, Nothing> =
@OptIn(ExperimentalTypeInference::class)
public inline fun <E, EE, A> Either<E, A>.recover(@BuilderInference recover: Raise<EE>.(E) -> A): Either<EE, A> {
contract { callsInPlace(recover, InvocationKind.AT_MOST_ONCE) }
return when(this) {
return when (this) {
is Left -> either { recover(this, value) }
is Right -> this@recover
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1358,4 +1358,4 @@ public inline fun <E> E.invalidNel(): ValidatedNel<E, Nothing> =
internal const val ValidatedDeprMsg = "Validated functionally is being merged into Either.\n"

private const val DeprAndNicheMsg =
"Validated functionaliy is being merged into Either, but this API is niche and will be removed in the future. If this method is crucial for you, please let us know on the Arrow Github. Thanks!\n https://github.com/arrow-kt/arrow/issues\n"
"Validated functionally is being merged into Either, but this API is niche and will be removed in the future. If this method is crucial for you, please let us know on the Arrow Github. Thanks!\n https://github.com/arrow-kt/arrow/issues\n"
Zordid marked this conversation as resolved.
Show resolved Hide resolved