Skip to content

Commit

Permalink
Clean up redundant syntax methods
Browse files Browse the repository at this point in the history
  • Loading branch information
travisbrown committed Nov 14, 2019
1 parent 4402e0d commit 7b30d5b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 72 deletions.
34 changes: 3 additions & 31 deletions core/src/main/scala/cats/syntax/applicativeError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,13 @@ private[syntax] trait ApplicativeErrorExtension {
new ApplicativeErrorExtensionOps(F)
}

@deprecated("Use methods on ApplicativeError", "2.1.0-RC1")
final private[syntax] class ApplicativeErrorExtensionOps[F[_], E](F: ApplicativeError[F, E]) {

/**
* Convert from scala.Option
*
* Example:
* {{{
* scala> import cats.implicits._
* scala> import cats.ApplicativeError
* scala> val F = ApplicativeError[Either[String, *], String]
*
* scala> F.fromOption(Some(1), "Empty")
* res0: scala.Either[String, Int] = Right(1)
*
* scala> F.fromOption(Option.empty[Int], "Empty")
* res1: scala.Either[String, Int] = Left(Empty)
* }}}
*/
@deprecated("Use fromOption on ApplicativeError", "2.1.0-RC1")
private[syntax] def fromOption[A](oa: Option[A], ifEmpty: => E): F[A] = F.fromOption(oa, ifEmpty)

/**
* Convert from cats.data.Validated
*
* Example:
* {{{
* scala> import cats.implicits._
* scala> import cats.ApplicativeError
*
* scala> ApplicativeError[Option, Unit].fromValidated(1.valid[Unit])
* res0: scala.Option[Int] = Some(1)
*
* scala> ApplicativeError[Option, Unit].fromValidated(().invalid[Int])
* res1: scala.Option[Int] = None
* }}}
*/
@deprecated("Use fromValidated on ApplicativeError", "2.1.0-RC1")
private[syntax] def fromValidated[A](x: Validated[E, A]): F[A] = F.fromValidated(x)
}

Expand Down
41 changes: 0 additions & 41 deletions core/src/main/scala/cats/syntax/foldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -284,58 +284,17 @@ final class FoldableOps0[F[_], A](private val fa: F[A]) extends AnyVal {
@deprecated("Use methods on Foldable", "2.1.0-RC1")
final private[syntax] class FoldableOps1[F[_]](private val F: Foldable[F]) extends AnyVal {

/**
* Separate this Foldable into a Tuple by a separating function `A => H[B, C]` for some `Bifoldable[H]`
* Equivalent to `Functor#map` and then `Alternative#separate`.
*
* {{{
* scala> import cats.implicits._, cats.Foldable, cats.data.Const
* scala> val list = List(1,2,3,4)
* scala> Foldable[List].partitionBifold(list)(a => ("value " + a.toString(), if (a % 2 == 0) -a else a))
* res0: (List[String], List[Int]) = (List(value 1, value 2, value 3, value 4),List(1, -2, 3, -4))
* scala> Foldable[List].partitionBifold(list)(a => Const[Int, Nothing with Any](a))
* res1: (List[Int], List[Nothing with Any]) = (List(1, 2, 3, 4),List())
* }}}
*/
@deprecated("Use partitionBifold on Foldable", "2.1.0-RC1")
def partitionBifold[H[_, _], A, B, C](fa: F[A])(f: A => H[B, C])(implicit A: Alternative[F],
H: Bifoldable[H]): (F[B], F[C]) =
F.partitionBifold[H, A, B, C](fa)(f)

/**
* Separate this Foldable into a Tuple by an effectful separating function `A => G[H[B, C]]` for some `Bifoldable[H]`
* Equivalent to `Traverse#traverse` over `Alternative#separate`
*
* {{{
* scala> import cats.implicits._, cats.Foldable, cats.data.Const
* scala> val list = List(1,2,3,4)
* `Const`'s second parameter is never instantiated, so we can use an impossible type:
* scala> Foldable[List].partitionBifoldM(list)(a => Option(Const[Int, Nothing with Any](a)))
* res0: Option[(List[Int], List[Nothing with Any])] = Some((List(1, 2, 3, 4),List()))
* }}}
*/
@deprecated("Use partitionBifoldM on Foldable", "2.1.0-RC1")
def partitionBifoldM[G[_], H[_, _], A, B, C](
fa: F[A]
)(f: A => G[H[B, C]])(implicit A: Alternative[F], M: Monad[G], H: Bifoldable[H]): G[(F[B], F[C])] =
F.partitionBifoldM[G, H, A, B, C](fa)(f)

/**
* Separate this Foldable into a Tuple by an effectful separating function `A => G[Either[B, C]]`
* Equivalent to `Traverse#traverse` over `Alternative#separate`
*
* {{{
* scala> import cats.implicits._, cats.Foldable, cats.Eval
* scala> val list = List(1,2,3,4)
* scala> val partitioned1 = Foldable[List].partitionEitherM(list)(a => if (a % 2 == 0) Eval.now(Either.left[String, Int](a.toString)) else Eval.now(Either.right[String, Int](a)))
* Since `Eval.now` yields a lazy computation, we need to force it to inspect the result:
* scala> partitioned1.value
* res0: (List[String], List[Int]) = (List(2, 4),List(1, 3))
* scala> val partitioned2 = Foldable[List].partitionEitherM(list)(a => Eval.later(Either.right(a * 4)))
* scala> partitioned2.value
* res1: (List[Nothing], List[Int]) = (List(),List(4, 8, 12, 16))
* }}}
*/
@deprecated("Use partitionEitherM on Foldable", "2.1.0-RC1")
def partitionEitherM[G[_], A, B, C](fa: F[A])(f: A => G[Either[B, C]])(implicit A: Alternative[F],
M: Monad[G]): G[(F[B], F[C])] =
Expand Down

0 comments on commit 7b30d5b

Please sign in to comment.