diff --git a/core/src/main/scala/cats/data/StateT.scala b/core/src/main/scala/cats/data/StateT.scala index 7eafa57f72..61b643cba4 100644 --- a/core/src/main/scala/cats/data/StateT.scala +++ b/core/src/main/scala/cats/data/StateT.scala @@ -30,27 +30,6 @@ final class StateT[F[_], S, A](val runF: F[S => F[(S, A)]]) extends Serializable def map[B](f: A => B)(implicit F: Functor[F]): StateT[F, S, B] = transform { case (s, a) => (s, f(a)) } - def map2[B, Z](sb: StateT[F, S, B])(fn: (A, B) => Z)(implicit F: FlatMap[F]): StateT[F, S, Z] = - StateT.applyF(F.map2(runF, sb.runF) { (ssa, ssb) => - ssa.andThen { fsa => - F.flatMap(fsa) { case (s, a) => - F.map(ssb(s)) { case (s, b) => (s, fn(a, b)) } - } - } - }) - - def map2Eval[B, Z](sb: Eval[StateT[F, S, B]])(fn: (A, B) => Z)(implicit F: FlatMap[F]): Eval[StateT[F, S, Z]] = - F.map2Eval(runF, sb.map(_.runF)) { (ssa, ssb) => - ssa.andThen { fsa => - F.flatMap(fsa) { case (s, a) => - F.map(ssb(s)) { case (s, b) => (s, fn(a, b)) } - } - } - }.map(StateT.applyF) - - def product[B](sb: StateT[F, S, B])(implicit F: FlatMap[F]): StateT[F, S, (A, B)] = - map2(sb)((_, _)) - /** * Run with the provided initial state value */ @@ -263,20 +242,8 @@ private[data] sealed trait StateTMonad[F[_], S] extends Monad[StateT[F, S, ?]] { def flatMap[A, B](fa: StateT[F, S, A])(f: A => StateT[F, S, B]): StateT[F, S, B] = fa.flatMap(f) - override def ap[A, B](ff: StateT[F, S, A => B])(fa: StateT[F, S, A]): StateT[F, S, B] = - ff.map2(fa) { case (f, a) => f(a) } - override def map[A, B](fa: StateT[F, S, A])(f: A => B): StateT[F, S, B] = fa.map(f) - override def map2[A, B, Z](fa: StateT[F, S, A], fb: StateT[F, S, B])(fn: (A, B) => Z): StateT[F, S, Z] = - fa.map2(fb)(fn) - - override def map2Eval[A, B, Z](fa: StateT[F, S, A], fb: Eval[StateT[F, S, B]])(fn: (A, B) => Z): Eval[StateT[F, S, Z]] = - fa.map2Eval(fb)(fn) - - override def product[A, B](fa: StateT[F, S, A], fb: StateT[F, S, B]): StateT[F, S, (A, B)] = - fa.product(fb) - def tailRecM[A, B](a: A)(f: A => StateT[F, S, Either[A, B]]): StateT[F, S, B] = StateT[F, S, B](s => F.tailRecM[(S, A), (S, B)]((s, a)) { case (s, a) => F.map(f(a).run(s)) { case (s, ab) => ab.bimap((s, _), (s, _)) } diff --git a/laws/src/main/scala/cats/laws/discipline/Arbitrary.scala b/laws/src/main/scala/cats/laws/discipline/Arbitrary.scala index d67b4c0b02..1d80831511 100644 --- a/laws/src/main/scala/cats/laws/discipline/Arbitrary.scala +++ b/laws/src/main/scala/cats/laws/discipline/Arbitrary.scala @@ -167,8 +167,8 @@ object arbitrary extends ArbitraryInstances0 { private[discipline] sealed trait ArbitraryInstances0 { - implicit def catsLawArbitraryForStateT[F[_]: Applicative, S, A](implicit AS: Arbitrary[S], CS: Cogen[S], F: Arbitrary[F[(S, A)]]): Arbitrary[StateT[F, S, A]] = - Arbitrary(Arbitrary.arbitrary[S => F[(S, A)]].map(StateT(_))) + implicit def catsLawArbitraryForStateT[F[_], S, A](implicit F: Arbitrary[F[S => F[(S, A)]]]): Arbitrary[StateT[F, S, A]] = + Arbitrary(F.arbitrary.map(StateT.applyF)) implicit def catsLawsArbitraryForWriterT[F[_], L, V](implicit F: Arbitrary[F[(L, V)]]): Arbitrary[WriterT[F, L, V]] = Arbitrary(F.arbitrary.map(WriterT(_)))