Skip to content

Commit

Permalink
MTL begone (#1751)
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundnoble authored Jul 27, 2017
1 parent ad17ffc commit 6fefa30
Show file tree
Hide file tree
Showing 88 changed files with 460 additions and 1,808 deletions.
19 changes: 19 additions & 0 deletions core/src/main/scala/cats/Alternative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ package cats
import simulacrum.typeclass

@typeclass trait Alternative[F[_]] extends Applicative[F] with MonoidK[F] { self =>
/**
* Fold over the inner structure to combine all of the values with
* our combine method inherited from MonoidK. The result is for us
* to accumulate all of the "interesting" values of the inner G, so
* if G is Option, we collect all the Some values, if G is Either,
* we collect all the Right values, etc.
*/
def unite[G[_], A](fga: F[G[A]])(implicit FM: Monad[F], G: Foldable[G]): F[A] =
FM.flatMap(fga) { ga =>
G.foldLeft(ga, empty[A])((acc, a) => combineK(acc, pure(a)))
}

/** Separate the inner foldable values into the "lefts" and "rights" */
def separate[G[_, _], A, B](fgab: F[G[A, B]])(implicit FM: Monad[F], G: Bifoldable[G]): (F[A], F[B]) = {
val as = FM.flatMap(fgab)(gab => G.bifoldMap(gab)(pure, _ => empty[A])(algebra[A]))
val bs = FM.flatMap(fgab)(gab => G.bifoldMap(gab)(_ => empty[B], pure)(algebra[B]))
(as, bs)
}

override def compose[G[_]: Applicative]: Alternative[λ[α => F[G[α]]]] =
new ComposedAlternative[F, G] {
val F = self
Expand Down
16 changes: 0 additions & 16 deletions core/src/main/scala/cats/Composed.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,22 +79,6 @@ private[cats] trait ComposedNonEmptyTraverse[F[_], G[_]] extends NonEmptyTravers
F.nonEmptyTraverse(fga)(ga => G.nonEmptyTraverse(ga)(f))
}

private[cats] trait ComposedTraverseFilter[F[_], G[_]] extends TraverseFilter[λ[α => F[G[α]]]] with ComposedTraverse[F, G] {
def F: Traverse[F]
def G: TraverseFilter[G]

override def traverseFilter[H[_]: Applicative, A, B](fga: F[G[A]])(f: A => H[Option[B]]): H[F[G[B]]] =
F.traverse[H, G[A], G[B]](fga)(ga => G.traverseFilter(ga)(f))
}

private[cats] trait ComposedFunctorFilter[F[_], G[_]] extends FunctorFilter[λ[α => F[G[α]]]] with ComposedFunctor[F, G] {
def F: Functor[F]
def G: FunctorFilter[G]

override def mapFilter[A, B](fga: F[G[A]])(f: A => Option[B]): F[G[B]] =
F.map(fga)(G.mapFilter(_)(f))
}

private[cats] trait ComposedReducible[F[_], G[_]] extends Reducible[λ[α => F[G[α]]]] with ComposedFoldable[F, G] { outer =>
def F: Reducible[F]
def G: Reducible[G]
Expand Down
6 changes: 0 additions & 6 deletions core/src/main/scala/cats/Functor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@ import simulacrum.typeclass
val G = Functor[G]
}

def composeFilter[G[_]: FunctorFilter]: FunctorFilter[λ[α => F[G[α]]]] =
new ComposedFunctorFilter[F, G] {
val F = self
val G = FunctorFilter[G]
}

override def composeContravariant[G[_]: Contravariant]: Contravariant[λ[α => F[G[α]]]] =
new ComposedCovariantContravariant[F, G] {
val F = self
Expand Down
62 changes: 0 additions & 62 deletions core/src/main/scala/cats/FunctorFilter.scala

This file was deleted.

28 changes: 0 additions & 28 deletions core/src/main/scala/cats/MonadCombine.scala

This file was deleted.

18 changes: 0 additions & 18 deletions core/src/main/scala/cats/MonadFilter.scala

This file was deleted.

17 changes: 0 additions & 17 deletions core/src/main/scala/cats/MonadReader.scala

This file was deleted.

52 changes: 0 additions & 52 deletions core/src/main/scala/cats/MonadState.scala

This file was deleted.

17 changes: 0 additions & 17 deletions core/src/main/scala/cats/MonadTrans.scala

This file was deleted.

28 changes: 0 additions & 28 deletions core/src/main/scala/cats/MonadWriter.scala

This file was deleted.

6 changes: 0 additions & 6 deletions core/src/main/scala/cats/Traverse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ import simulacrum.typeclass
val G = Traverse[G]
}

def composeFilter[G[_]: TraverseFilter]: TraverseFilter[λ[α => F[G[α]]]] =
new ComposedTraverseFilter[F, G] {
val F = self
val G = TraverseFilter[G]
}

override def map[A, B](fa: F[A])(f: A => B): F[B] =
traverse[Id, A, B](fa)(f)

Expand Down
65 changes: 0 additions & 65 deletions core/src/main/scala/cats/TraverseFilter.scala

This file was deleted.

Loading

0 comments on commit 6fefa30

Please sign in to comment.