Skip to content

Commit

Permalink
Remove arrow instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Itamar Ravid committed Sep 11, 2017
1 parent 3151311 commit 995d451
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 40 deletions.
30 changes: 1 addition & 29 deletions core/src/main/scala/cats/data/IndexedStateT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cats
package data

import cats.functor.{ Contravariant, Bifunctor, Profunctor, Strong }
import cats.arrow.Arrow
import cats.syntax.either._

/**
Expand Down Expand Up @@ -252,16 +251,11 @@ private[data] sealed abstract class IndexedStateTInstances3 extends IndexedState
new IndexedStateTBifunctor[F, SA] { implicit def F = F0 }
}

private[data] sealed abstract class IndexedStateTInstances4 extends IndexedStateTInstances5 {
private[data] sealed abstract class IndexedStateTInstances4 {
implicit def catsDataStrongForIndexedStateT[F[_], V](implicit F0: Monad[F]): Strong[IndexedStateT[F, ?, ?, V]] =
new IndexedStateTStrong[F, V] { implicit def F = F0 }
}

private[data] sealed abstract class IndexedStateTInstances5 {
implicit def catsDataArrowForIndexedStateT[F[_], V](implicit F0: Monad[F], V0: Monoid[V]): Arrow[IndexedStateT[F, ?, ?, V]] =
new IndexedStateTArrow[F, V] { implicit def F = F0; implicit def V = V0 }
}

// To workaround SI-7139 `object State` needs to be defined inside the package object
// together with the type alias.
private[data] abstract class StateFunctions {
Expand Down Expand Up @@ -337,28 +331,6 @@ private[data] sealed abstract class IndexedStateTStrong[F[_], V] extends Indexed
first(fa).dimap((_: (C, A)).swap)(_.swap)
}

private[data] sealed abstract class IndexedStateTArrow[F[_], V] extends IndexedStateTStrong[F, V] with Arrow[IndexedStateT[F, ?, ?, V]] {
implicit def F: Monad[F]
implicit def V: Monoid[V]

def lift[A, B](f: A => B): IndexedStateT[F, A, B, V] =
IndexedStateT { a =>
F.pure((f(a), V.empty))
}

def id[A]: IndexedStateT[F, A, A, V] =
IndexedStateT.pure(V.empty)

def compose[A, B, C](f: IndexedStateT[F, B, C, V], g: IndexedStateT[F, A, B, V]): IndexedStateT[F, A, C, V] =
IndexedStateT { a =>
F.flatMap(g.run(a)) { case (b, va) =>
F.map(f.run(b)) { case (c, vb) =>
(c, V.combine(va, vb))
}
}
}
}

private[data] sealed abstract class IndexedStateTMonad[F[_], S] extends IndexedStateTFunctor[F, S, S] with Monad[IndexedStateT[F, S, S, ?]] {
implicit def F: Monad[F]

Expand Down
11 changes: 0 additions & 11 deletions tests/src/test/scala/cats/tests/IndexedStateTTests.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cats
package tests

import cats.arrow.Arrow
import cats.data.{State, StateT, IndexedStateT, EitherT}
import cats.functor.{Contravariant, Bifunctor, Profunctor, Strong}
import cats.kernel.instances.tuple._
Expand Down Expand Up @@ -322,16 +321,6 @@ class IndexedStateTTests extends CatsSuite {
Strong[IndexedStateT[ListWrapper, ?, ?, Int]]
}

{
implicit val F: Monad[ListWrapper] = ListWrapper.monad
implicit val FS: Arrow[IndexedStateT[ListWrapper, ?, ?, Int]] = IndexedStateT.catsDataArrowForIndexedStateT

checkAll("IndexedStateT[ListWrapper, String, Int, Int]", ArrowTests[IndexedStateT[ListWrapper, ?, ?, Int]].arrow[String, String, String, Int, Int, Int])
checkAll("Arrow[IndexedStateT[ListWrapper, ?, ?, Int]]", SerializableTests.serializable(Arrow[IndexedStateT[ListWrapper, ?, ?, Int]]))

Arrow[IndexedStateT[ListWrapper, ?, ?, Int]]
}

{
// F has a Monad
implicit val F = ListWrapper.monad
Expand Down

0 comments on commit 995d451

Please sign in to comment.