From 0bae06d5758c2ca179fc2953e29b1228d72fc900 Mon Sep 17 00:00:00 2001 From: peterneyens Date: Wed, 1 Jun 2016 14:30:02 +0200 Subject: [PATCH] Make the usage of kind projections more consistant. --- core/src/main/scala/cats/Alternative.scala | 4 ++-- core/src/main/scala/cats/Applicative.scala | 4 ++-- core/src/main/scala/cats/Foldable.scala | 4 ++-- core/src/main/scala/cats/MonoidK.scala | 4 ++-- core/src/main/scala/cats/Reducible.scala | 4 ++-- core/src/main/scala/cats/SemigroupK.scala | 4 ++-- core/src/main/scala/cats/arrow/Category.scala | 4 ++-- core/src/main/scala/cats/arrow/Compose.scala | 4 ++-- core/src/main/scala/cats/data/Kleisli.scala | 4 ++-- free/src/main/scala/cats/free/FreeApplicative.scala | 6 +++--- .../test/scala/cats/free/FreeApplicativeTests.scala | 2 +- tests/src/test/scala/cats/tests/TransLiftTests.scala | 11 +++++------ 12 files changed, 27 insertions(+), 28 deletions(-) diff --git a/core/src/main/scala/cats/Alternative.scala b/core/src/main/scala/cats/Alternative.scala index 369bd0bbf87..48095ce7e79 100644 --- a/core/src/main/scala/cats/Alternative.scala +++ b/core/src/main/scala/cats/Alternative.scala @@ -7,7 +7,7 @@ import simulacrum.typeclass /** * Compose this `Alternative` instance with an [[Applicative]] instance. */ - override def compose[G[_]](implicit GG: Applicative[G]): Alternative[λ[α => F[G[α]]]] = + override def compose[G[_]](implicit GG: Applicative[G]): Alternative[Lambda[X => F[G[X]]]] = new CompositeAlternative[F, G] { implicit def F: Alternative[F] = self implicit def G: Applicative[G] = GG @@ -15,7 +15,7 @@ import simulacrum.typeclass } trait CompositeAlternative[F[_], G[_]] - extends Alternative[λ[α => F[G[α]]]] with CompositeApplicative[F, G] with CompositeMonoidK[F, G] { + extends Alternative[Lambda[X => F[G[X]]]] with CompositeApplicative[F, G] with CompositeMonoidK[F, G] { implicit def F: Alternative[F] implicit def G: Applicative[G] diff --git a/core/src/main/scala/cats/Applicative.scala b/core/src/main/scala/cats/Applicative.scala index 41532316cfa..16d69963bcf 100644 --- a/core/src/main/scala/cats/Applicative.scala +++ b/core/src/main/scala/cats/Applicative.scala @@ -45,7 +45,7 @@ import cats.std.list._ * * Applicative[Option].compose[List].pure(10) = Some(List(10)) */ - def compose[G[_]](implicit GG : Applicative[G]): Applicative[λ[α => F[G[α]]]] = + def compose[G[_]](implicit GG : Applicative[G]): Applicative[Lambda[X => F[G[X]]]] = new CompositeApplicative[F,G] { implicit def F: Applicative[F] = self implicit def G: Applicative[G] = GG @@ -61,7 +61,7 @@ import cats.std.list._ } trait CompositeApplicative[F[_],G[_]] - extends Applicative[λ[α => F[G[α]]]] with CompositeApply[F,G] { + extends Applicative[Lambda[X => F[G[X]]]] with CompositeApply[F,G] { implicit def F: Applicative[F] implicit def G: Applicative[G] diff --git a/core/src/main/scala/cats/Foldable.scala b/core/src/main/scala/cats/Foldable.scala index a25943547cd..679d964f24a 100644 --- a/core/src/main/scala/cats/Foldable.scala +++ b/core/src/main/scala/cats/Foldable.scala @@ -273,7 +273,7 @@ import simulacrum.typeclass * Compose this `Foldable[F]` with a `Foldable[G]` to create * a `Foldable[F[G]]` instance. */ - def compose[G[_]](implicit ev: Foldable[G]): Foldable[λ[α => F[G[α]]]] = + def compose[G[_]](implicit ev: Foldable[G]): Foldable[Lambda[X => F[G[X]]]] = new CompositeFoldable[F, G] { val F = self val G = ev @@ -283,7 +283,7 @@ import simulacrum.typeclass /** * Methods that apply to 2 nested Foldable instances */ -trait CompositeFoldable[F[_], G[_]] extends Foldable[λ[α => F[G[α]]]] { +trait CompositeFoldable[F[_], G[_]] extends Foldable[Lambda[X => F[G[X]]]] { implicit def F: Foldable[F] implicit def G: Foldable[G] diff --git a/core/src/main/scala/cats/MonoidK.scala b/core/src/main/scala/cats/MonoidK.scala index 6cdcdb73682..4bbaa2a241b 100644 --- a/core/src/main/scala/cats/MonoidK.scala +++ b/core/src/main/scala/cats/MonoidK.scala @@ -32,7 +32,7 @@ import simulacrum.typeclass /** * Compose this MonoidK with an arbitrary type constructor */ - override def composeK[G[_]]: MonoidK[λ[α => F[G[α]]]] = + override def composeK[G[_]]: MonoidK[Lambda[X => F[G[X]]]] = new CompositeMonoidK[F, G] { implicit def F: MonoidK[F] = self } @@ -48,7 +48,7 @@ import simulacrum.typeclass } trait CompositeMonoidK[F[_],G[_]] - extends MonoidK[λ[α => F[G[α]]]] with CompositeSemigroupK[F, G] { + extends MonoidK[Lambda[X => F[G[X]]]] with CompositeSemigroupK[F, G] { implicit def F: MonoidK[F] diff --git a/core/src/main/scala/cats/Reducible.scala b/core/src/main/scala/cats/Reducible.scala index adfcb48a69f..4acff93996e 100644 --- a/core/src/main/scala/cats/Reducible.scala +++ b/core/src/main/scala/cats/Reducible.scala @@ -110,7 +110,7 @@ import simulacrum.typeclass /** * Compose two `Reducible` instances into a new one. */ - def compose[G[_]](implicit GG: Reducible[G]): Reducible[λ[α => F[G[α]]]] = + def compose[G[_]](implicit GG: Reducible[G]): Reducible[Lambda[X => F[G[X]]]] = new CompositeReducible[F, G] { implicit def F: Reducible[F] = self implicit def G: Reducible[G] = GG @@ -126,7 +126,7 @@ import simulacrum.typeclass * `F[A]`) and a `Reducible[G]` instance (which can reduce `G[A]` * values), this class is able to reduce `F[G[A]]` values. */ -trait CompositeReducible[F[_], G[_]] extends Reducible[λ[α => F[G[α]]]] with CompositeFoldable[F, G] { +trait CompositeReducible[F[_], G[_]] extends Reducible[Lambda[X => F[G[X]]]] with CompositeFoldable[F, G] { implicit def F: Reducible[F] implicit def G: Reducible[G] diff --git a/core/src/main/scala/cats/SemigroupK.scala b/core/src/main/scala/cats/SemigroupK.scala index 113228cb3bd..06e55ae54d8 100644 --- a/core/src/main/scala/cats/SemigroupK.scala +++ b/core/src/main/scala/cats/SemigroupK.scala @@ -31,7 +31,7 @@ import simulacrum.typeclass /** * Compose this SemigroupK with an arbitrary type constructor */ - def composeK[G[_]]: SemigroupK[λ[α => F[G[α]]]] = + def composeK[G[_]]: SemigroupK[Lambda[X => F[G[X]]]] = new CompositeSemigroupK[F, G] { implicit def F: SemigroupK[F] = self } @@ -46,7 +46,7 @@ import simulacrum.typeclass } trait CompositeSemigroupK[F[_],G[_]] - extends SemigroupK[λ[α => F[G[α]]]] { + extends SemigroupK[Lambda[X => F[G[X]]]] { implicit def F: SemigroupK[F] diff --git a/core/src/main/scala/cats/arrow/Category.scala b/core/src/main/scala/cats/arrow/Category.scala index fea57033653..3e17927c7cd 100644 --- a/core/src/main/scala/cats/arrow/Category.scala +++ b/core/src/main/scala/cats/arrow/Category.scala @@ -8,8 +8,8 @@ trait Category[F[_, _]] extends Compose[F] { self => def id[A]: F[A, A] - override def algebraK: MonoidK[λ[α => F[α, α]]] = - new MonoidK[λ[α => F[α, α]]] { + override def algebraK: MonoidK[Lambda[X => F[X, X]]] = + new MonoidK[Lambda[X => F[X, X]]] { def empty[A]: F[A, A] = id def combineK[A](f1: F[A, A], f2: F[A, A]): F[A, A] = self.compose(f1, f2) } diff --git a/core/src/main/scala/cats/arrow/Compose.scala b/core/src/main/scala/cats/arrow/Compose.scala index 73f5735955d..1e012f49cd6 100644 --- a/core/src/main/scala/cats/arrow/Compose.scala +++ b/core/src/main/scala/cats/arrow/Compose.scala @@ -10,8 +10,8 @@ trait Compose[F[_, _]] extends Serializable { self => def andThen[A, B, C](f: F[A, B], g: F[B, C]): F[A, C] = compose(g, f) - def algebraK: SemigroupK[λ[α => F[α, α]]] = - new SemigroupK[λ[α => F[α, α]]] { + def algebraK: SemigroupK[Lambda[X => F[X, X]]] = + new SemigroupK[Lambda[X => F[X, X]]] { def combineK[A](f1: F[A, A], f2: F[A, A]): F[A, A] = self.compose(f1, f2) } diff --git a/core/src/main/scala/cats/data/Kleisli.scala b/core/src/main/scala/cats/data/Kleisli.scala index 6f06bb1e179..e0fa22b2f98 100644 --- a/core/src/main/scala/cats/data/Kleisli.scala +++ b/core/src/main/scala/cats/data/Kleisli.scala @@ -42,8 +42,8 @@ final case class Kleisli[F[_], A, B](run: A => F[B]) { self => def traverse[G[_]](f: G[A])(implicit F: Applicative[F], G: Traverse[G]): F[G[B]] = G.traverse(f)(run) - def lift[G[_]](implicit G: Applicative[G]): Kleisli[λ[α => G[F[α]]], A, B] = - Kleisli[λ[α => G[F[α]]], A, B](a => Applicative[G].pure(run(a))) + def lift[G[_]](implicit G: Applicative[G]): Kleisli[Lambda[X => G[F[X]]], A, B] = + Kleisli[Lambda[X => G[F[X]]], A, B](a => Applicative[G].pure(run(a))) def local[AA](f: AA => A): Kleisli[F, AA, B] = Kleisli(f.andThen(run)) diff --git a/free/src/main/scala/cats/free/FreeApplicative.scala b/free/src/main/scala/cats/free/FreeApplicative.scala index b581ca5a4dc..480248b260e 100644 --- a/free/src/main/scala/cats/free/FreeApplicative.scala +++ b/free/src/main/scala/cats/free/FreeApplicative.scala @@ -27,7 +27,7 @@ sealed abstract class FreeApplicative[F[_], A] extends Product with Serializable /** Interprets/Runs the sequence of operations using the semantics of Applicative G * Tail recursive only if G provides tail recursive interpretation (ie G is FreeMonad) */ - final def foldMap[G[_]](f: FunctionK[F,G])(implicit G: Applicative[G]): G[A] = + final def foldMap[G[_]](f: FunctionK[F, G])(implicit G: Applicative[G]): G[A] = this match { case Pure(a) => G.pure(a) case Ap(pivot, fn) => G.map2(f(pivot), fn.foldMap(f))((a, g) => g(a)) @@ -40,7 +40,7 @@ sealed abstract class FreeApplicative[F[_], A] extends Product with Serializable foldMap(FunctionK.id[F]) /** Interpret this algebra into another FreeApplicative */ - final def compile[G[_]](f: FunctionK[F,G]): FA[G, A] = + final def compile[G[_]](f: FunctionK[F, G]): FA[G, A] = foldMap[FA[G, ?]] { new FunctionK[F, FA[G, ?]] { def apply[B](fa: F[B]): FA[G, B] = lift(f(fa)) @@ -48,7 +48,7 @@ sealed abstract class FreeApplicative[F[_], A] extends Product with Serializable } /** Interpret this algebra into a Monoid */ - final def analyze[M:Monoid](f: FunctionK[F,λ[α => M]]): M = + final def analyze[M:Monoid](f: FunctionK[F, Lambda[X => M]]): M = foldMap[Const[M, ?]](new (FunctionK[F,Const[M, ?]]) { def apply[X](x: F[X]): Const[M,X] = Const(f(x)) }).getConst diff --git a/free/src/test/scala/cats/free/FreeApplicativeTests.scala b/free/src/test/scala/cats/free/FreeApplicativeTests.scala index 91096c92dfc..97d0dbc3e42 100644 --- a/free/src/test/scala/cats/free/FreeApplicativeTests.scala +++ b/free/src/test/scala/cats/free/FreeApplicativeTests.scala @@ -120,7 +120,7 @@ class FreeApplicativeTests extends CatsSuite { val z = Apply[Dsl].map2(x, y)((_, _) => ()) - val asString: FunctionK[Id,λ[α => String]] = new FunctionK[Id,λ[α => String]] { + val asString: FunctionK[Id, Lambda[X => String]] = new FunctionK[Id, Lambda[X => String]] { def apply[A](a: A): String = a.toString } diff --git a/tests/src/test/scala/cats/tests/TransLiftTests.scala b/tests/src/test/scala/cats/tests/TransLiftTests.scala index 1661941745f..830a4051e23 100644 --- a/tests/src/test/scala/cats/tests/TransLiftTests.scala +++ b/tests/src/test/scala/cats/tests/TransLiftTests.scala @@ -23,17 +23,16 @@ class TransLiftTests extends CatsSuite { } test("transLift for XorT, OptionT, WriterT requires only Functor") { - val d: XorT[JustFunctor, Int, Int] = JustFunctor(1).liftT[({type λ[α[_], β] = XorT[α, Int, β]})#λ] + val d: XorT[JustFunctor, Int, Int] = JustFunctor(1).liftT[Lambda[(X[_], Y) => XorT[X, Int, Y]]] val c: OptionT[JustFunctor, Int] = JustFunctor(1).liftT[OptionT] - val a: WriterT[JustFunctor, Int, Int] = JustFunctor(1).liftT[({type λ[α[_], β] = WriterT[α, Int, β]})#λ] - + val a: WriterT[JustFunctor, Int, Int] = JustFunctor(1).liftT[Lambda[(X[_], Y) => WriterT[X, Int, Y]]] } test("transLift for StateT requires Applicative Functor") { - val f: StateT[JustAp, Int, Int] = JustAp(1).liftT[({type λ[α[_], β] = StateT[α, Int, β]})#λ] + val f: StateT[JustAp, Int, Int] = JustAp(1).liftT[Lambda[(X[_], Y) => StateT[X, Int, Y]]] } - test("transLift for, Kleisli doesn't require anything of the wrapped value"){ - val e: Kleisli[NoTypeclass, Int, Int] = NoTypeclass(1).liftT[({type λ[α[_], β] = Kleisli[α, Int, β]})#λ] + test("transLift for Kleisli doesn't require anything of the wrapped value"){ + val e: Kleisli[NoTypeclass, Int, Int] = NoTypeclass(1).liftT[Lambda[(X[_], Y) => Kleisli[X, Int, Y]]] } }