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 @@ -772,7 +772,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 +1338,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 @@ -2320,6 +2322,7 @@ public fun <A, B> Either<A, B>.combine(other: Either<A, B>, combineLeft: (A, A)
public fun <A, B> Either<A, B>.combine(SGA: Semigroup<A>, SGB: Semigroup<B>, b: Either<A, B>): Either<A, B> =
combine(b, SGA::combine, SGB::combine)


@Deprecated(
MonoidDeprecation,
ReplaceWith(
Expand Down Expand Up @@ -2691,7 +2694,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 @@ -1313,7 +1313,7 @@ public inline fun <A> A.validNel(): ValidatedNel<Nothing, A> =
public inline fun <E> E.invalidNel(): ValidatedNel<E, Nothing> =
Validated.invalidNel(this)

internal const val ValidatedDeprMsg = "Validated functionally is being merged into Either.\n"
internal const val ValidatedDeprMsg = "Validated functionality 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 functionality 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"