From ce8d4fa8b9ff8088bb781d53b94f89e863369a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20H=C3=B6fer?= Date: Mon, 24 Sep 2018 20:36:01 +0200 Subject: [PATCH] align type parameter of smart constructor with Validated (#2525) --- core/src/main/scala/cats/data/Validated.scala | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/core/src/main/scala/cats/data/Validated.scala b/core/src/main/scala/cats/data/Validated.scala index 4cc8d56884..d5b254a363 100644 --- a/core/src/main/scala/cats/data/Validated.scala +++ b/core/src/main/scala/cats/data/Validated.scala @@ -514,7 +514,7 @@ private[data] class ValidatedApplicative[E: Semigroup] extends CommutativeApplic private[data] trait ValidatedFunctions { /** - * Converts an `A` to a `Validated[A, B]`. + * Converts an `E` to a `Validated[E, A]`. * * For example: * {{{ @@ -522,10 +522,10 @@ private[data] trait ValidatedFunctions { * res0: Validated[IllegalArgumentException, String] = Invalid(java.lang.IllegalArgumentException: Argument is nonzero) * }}} */ - def invalid[A, B](a: A): Validated[A, B] = Validated.Invalid(a) + def invalid[E, A](e: E): Validated[E, A] = Validated.Invalid(e) /** - * Converts an `A` to a `ValidatedNel[A, B]`. + * Converts an `E` to a `ValidatedNel[E, A]`. * * For example: * {{{ @@ -533,10 +533,10 @@ private[data] trait ValidatedFunctions { * res0: ValidatedNel[IllegalArgumentException, String] = Invalid(NonEmptyList(java.lang.IllegalArgumentException: Argument is nonzero)) * }}} */ - def invalidNel[A, B](a: A): ValidatedNel[A, B] = Validated.Invalid(NonEmptyList(a, Nil)) + def invalidNel[E, A](e: E): ValidatedNel[E, A] = Validated.Invalid(NonEmptyList(e, Nil)) /** - * Converts a `B` to a `Validated[A, B]`. + * Converts a `A` to a `Validated[E, A]`. * * For example: * {{{ @@ -544,10 +544,10 @@ private[data] trait ValidatedFunctions { * res0: Validated[IllegalArgumentException, String] = Valid(Hello world) * }}} */ - def valid[A, B](b: B): Validated[A, B] = Validated.Valid(b) + def valid[E, A](a: A): Validated[E, A] = Validated.Valid(a) /** - * Converts a `B` to a `ValidatedNel[A, B]`. + * Converts a `A` to a `ValidatedNel[E, A]`. * * For example: * {{{ @@ -555,7 +555,7 @@ private[data] trait ValidatedFunctions { * res0: ValidatedNel[IllegalArgumentException, String] = Valid(Hello world) * }}} */ - def validNel[A, B](b: B): ValidatedNel[A, B] = Validated.Valid(b) + def validNel[E, A](a: A): ValidatedNel[E, A] = Validated.Valid(a) def catchNonFatal[A](f: => A): Validated[Throwable, A] = try { @@ -589,16 +589,16 @@ private[data] trait ValidatedFunctions { def fromIor[A, B](ior: Ior[A, B]): Validated[A, B] = ior.fold(invalid, valid, (_, b) => valid(b)) /** - * If the condition is satisfied, return the given `B` as valid, - * otherwise return the given `A` as invalid. + * If the condition is satisfied, return the given `A` as valid, + * otherwise return the given `E` as invalid. */ - final def cond[A, B](test: Boolean, b: => B, a: => A): Validated[A, B] = - if (test) valid(b) else invalid(a) + final def cond[E, A](test: Boolean, a: => A, e: => E): Validated[E, A] = + if (test) valid(a) else invalid(e) /** - * If the condition is satisfied, return the given `B` as valid NEL, - * otherwise return the given `A` as invalid NEL. + * If the condition is satisfied, return the given `A` as valid NEL, + * otherwise return the given `E` as invalid NEL. */ - final def condNel[A, B](test: Boolean, b: => B, a: => A): ValidatedNel[A, B] = - if (test) validNel(b) else invalidNel(a) + final def condNel[E, A](test: Boolean, a: => A, e: => E): ValidatedNel[E, A] = + if (test) validNel(a) else invalidNel(e) }