Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MTL is dead, long live MTL #1751

Merged
merged 2 commits into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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