diff --git a/core/src/main/scala-2.12/cats/instances/stream.scala b/core/src/main/scala-2.12/cats/instances/stream.scala index 40c8a45484..4bae0aa921 100644 --- a/core/src/main/scala-2.12/cats/instances/stream.scala +++ b/core/src/main/scala-2.12/cats/instances/stream.scala @@ -176,10 +176,10 @@ trait StreamInstances extends cats.kernel.instances.StreamInstances { def applicative: Applicative[ZipStream] = ZipStream.catsDataAlternativeForZipStream def sequential: ZipStream ~> Stream = - λ[ZipStream ~> Stream](_.value) + new (ZipStream ~> Stream) { def apply[A](a: ZipStream[A]): Stream[A] = a.value } def parallel: Stream ~> ZipStream = - λ[Stream ~> ZipStream](v => new ZipStream(v)) + new (Stream ~> ZipStream) { def apply[A](v: Stream[A]): ZipStream[A] = new ZipStream(v) } } } diff --git a/core/src/main/scala-2.13+/cats/data/NonEmptyLazyList.scala b/core/src/main/scala-2.13+/cats/data/NonEmptyLazyList.scala index eb49b39c19..4e94ec5422 100644 --- a/core/src/main/scala-2.13+/cats/data/NonEmptyLazyList.scala +++ b/core/src/main/scala-2.13+/cats/data/NonEmptyLazyList.scala @@ -506,12 +506,15 @@ sealed abstract private[data] class NonEmptyLazyListInstances extends NonEmptyLa def monad: Monad[NonEmptyLazyList] = NonEmptyLazyList.catsDataInstancesForNonEmptyLazyList def sequential: OneAnd[ZipLazyList, *] ~> NonEmptyLazyList = - λ[OneAnd[ZipLazyList, *] ~> NonEmptyLazyList](znell => - NonEmptyLazyList.fromLazyListPrepend(znell.head, znell.tail.value) - ) + new (OneAnd[ZipLazyList, *] ~> NonEmptyLazyList) { + def apply[A](znell: OneAnd[ZipLazyList, A]): NonEmptyLazyList[A] = + NonEmptyLazyList.fromLazyListPrepend(znell.head, znell.tail.value) + } def parallel: NonEmptyLazyList ~> OneAnd[ZipLazyList, *] = - λ[NonEmptyLazyList ~> OneAnd[ZipLazyList, *]](nell => OneAnd(nell.head, ZipLazyList(nell.tail))) + new (NonEmptyLazyList ~> OneAnd[ZipLazyList, *]) { + def apply[A](nell: NonEmptyLazyList[A]): OneAnd[ZipLazyList, A] = OneAnd(nell.head, ZipLazyList(nell.tail)) + } } } diff --git a/core/src/main/scala-2.13+/cats/instances/lazyList.scala b/core/src/main/scala-2.13+/cats/instances/lazyList.scala index d138f089d6..e8757ba799 100644 --- a/core/src/main/scala-2.13+/cats/instances/lazyList.scala +++ b/core/src/main/scala-2.13+/cats/instances/lazyList.scala @@ -182,9 +182,9 @@ trait LazyListInstances extends cats.kernel.instances.LazyListInstances { def applicative: Applicative[ZipLazyList] = ZipLazyList.catsDataAlternativeForZipLazyList def sequential: ZipLazyList ~> LazyList = - λ[ZipLazyList ~> LazyList](_.value) + new (ZipLazyList ~> LazyList) { def apply[B](zll: ZipLazyList[B]): LazyList[B] = zll.value } def parallel: LazyList ~> ZipLazyList = - λ[LazyList ~> ZipLazyList](v => new ZipLazyList(v)) + new (LazyList ~> ZipLazyList) { def apply[B](ll: LazyList[B]): ZipLazyList[B] = new ZipLazyList(ll) } } } diff --git a/core/src/main/scala-2.13+/cats/instances/stream.scala b/core/src/main/scala-2.13+/cats/instances/stream.scala index 640d3b7ec4..e62f3be8dd 100644 --- a/core/src/main/scala-2.13+/cats/instances/stream.scala +++ b/core/src/main/scala-2.13+/cats/instances/stream.scala @@ -179,10 +179,10 @@ trait StreamInstances extends cats.kernel.instances.StreamInstances { def applicative: Applicative[ZipStream] = ZipStream.catsDataAlternativeForZipStream def sequential: ZipStream ~> Stream = - λ[ZipStream ~> Stream](_.value) + new (ZipStream ~> Stream) { def apply[A](a: ZipStream[A]): Stream[A] = a.value } def parallel: Stream ~> ZipStream = - λ[Stream ~> ZipStream](v => new ZipStream(v)) + new (Stream ~> ZipStream) { def apply[A](v: Stream[A]): ZipStream[A] = new ZipStream(v) } } } diff --git a/core/src/main/scala/cats/InjectK.scala b/core/src/main/scala/cats/InjectK.scala index 4e65292374..73c2bcba6d 100644 --- a/core/src/main/scala/cats/InjectK.scala +++ b/core/src/main/scala/cats/InjectK.scala @@ -37,21 +37,26 @@ sealed abstract private[cats] class InjectKInstances { new InjectK[F, F] { val inj = FunctionK.id[F] - val prj = λ[FunctionK[F, λ[α => Option[F[α]]]]](Some(_)) + val prj = new FunctionK[F, λ[α => Option[F[α]]]] { def apply[A](a: F[A]): Option[F[A]] = Some(a) } } implicit def catsLeftInjectKInstance[F[_], G[_]]: InjectK[F, EitherK[F, G, *]] = new InjectK[F, EitherK[F, G, *]] { - val inj = λ[FunctionK[F, EitherK[F, G, *]]](EitherK.leftc(_)) + val inj = new FunctionK[F, EitherK[F, G, *]] { def apply[A](a: F[A]): EitherK[F, G, A] = EitherK.leftc(a) } - val prj = λ[FunctionK[EitherK[F, G, *], λ[α => Option[F[α]]]]](_.run.left.toOption) + val prj = new FunctionK[EitherK[F, G, *], λ[α => Option[F[α]]]] { + def apply[A](a: EitherK[F, G, A]): Option[F[A]] = a.run.left.toOption + } } implicit def catsRightInjectKInstance[F[_], G[_], H[_]](implicit I: InjectK[F, G]): InjectK[F, EitherK[H, G, *]] = new InjectK[F, EitherK[H, G, *]] { - val inj = λ[FunctionK[G, EitherK[H, G, *]]](EitherK.rightc(_)).compose(I.inj) + val inj = new FunctionK[G, EitherK[H, G, *]] { def apply[A](a: G[A]): EitherK[H, G, A] = EitherK.rightc(a) } + .compose(I.inj) - val prj = λ[FunctionK[EitherK[H, G, *], λ[α => Option[F[α]]]]](_.run.toOption.flatMap(I.prj(_))) + val prj = new FunctionK[EitherK[H, G, *], λ[α => Option[F[α]]]] { + def apply[A](a: EitherK[H, G, A]): Option[F[A]] = a.run.toOption.flatMap(I.prj(_)) + } } } diff --git a/core/src/main/scala/cats/arrow/FunctionK.scala b/core/src/main/scala/cats/arrow/FunctionK.scala index b503c5e5a8..7309cb28d5 100644 --- a/core/src/main/scala/cats/arrow/FunctionK.scala +++ b/core/src/main/scala/cats/arrow/FunctionK.scala @@ -28,7 +28,7 @@ trait FunctionK[F[_], G[_]] extends Serializable { self => * transformation applied last. */ def compose[E[_]](f: FunctionK[E, F]): FunctionK[E, G] = - λ[FunctionK[E, G]](fa => self(f(fa))) + new FunctionK[E, G] { def apply[A](fa: E[A]): G[A] = self(f(fa)) } /** * Composes two instances of FunctionK into a new FunctionK with this @@ -45,7 +45,7 @@ trait FunctionK[F[_], G[_]] extends Serializable { self => * `h` will be used to transform right `H` values. */ def or[H[_]](h: FunctionK[H, G]): FunctionK[EitherK[F, H, *], G] = - λ[FunctionK[EitherK[F, H, *], G]](fa => fa.fold(self, h)) + new FunctionK[EitherK[F, H, *], G] { def apply[A](fa: EitherK[F, H, A]): G[A] = fa.fold(self, h) } /** * Composes two instances of `FunctionK` into a new `FunctionK` that transforms @@ -61,7 +61,7 @@ trait FunctionK[F[_], G[_]] extends Serializable { self => * }}} */ def and[H[_]](h: FunctionK[F, H]): FunctionK[F, Tuple2K[G, H, *]] = - λ[FunctionK[F, Tuple2K[G, H, *]]](fa => Tuple2K(self(fa), h(fa))) + new FunctionK[F, Tuple2K[G, H, *]] { def apply[A](fa: F[A]): Tuple2K[G, H, A] = Tuple2K(self(fa), h(fa)) } } object FunctionK { @@ -69,7 +69,7 @@ object FunctionK { /** * The identity transformation of `F` to `F` */ - def id[F[_]]: FunctionK[F, F] = λ[FunctionK[F, F]](fa => fa) + def id[F[_]]: FunctionK[F, F] = new FunctionK[F, F] { def apply[A](fa: F[A]): F[A] = fa } /** * Lifts function `f` of `F[A] => G[A]` into a `FunctionK[F, G]`. diff --git a/core/src/main/scala/cats/data/ContT.scala b/core/src/main/scala/cats/data/ContT.scala index 2ec7693760..704da67846 100644 --- a/core/src/main/scala/cats/data/ContT.scala +++ b/core/src/main/scala/cats/data/ContT.scala @@ -99,7 +99,9 @@ object ContT { * }}} */ def liftK[M[_], B](implicit M: FlatMap[M]): M ~> ContT[M, B, *] = - λ[M ~> ContT[M, B, *]](ContT.liftF(_)) + new (M ~> ContT[M, B, *]) { + def apply[A](ma: M[A]): ContT[M, B, A] = ContT.liftF(ma) + } /** * Similar to [[pure]] but evaluation of the argument is deferred. diff --git a/core/src/main/scala/cats/data/EitherT.scala b/core/src/main/scala/cats/data/EitherT.scala index d5bcc4c767..e50d6f2d94 100644 --- a/core/src/main/scala/cats/data/EitherT.scala +++ b/core/src/main/scala/cats/data/EitherT.scala @@ -740,7 +740,7 @@ object EitherT extends EitherTInstances { * }}} */ final def liftK[F[_], A](implicit F: Functor[F]): F ~> EitherT[F, A, *] = - λ[F ~> EitherT[F, A, *]](right(_)) + new (F ~> EitherT[F, A, *]) { def apply[B](fb: F[B]): EitherT[F, A, B] = right(fb) } @deprecated("Use EitherT.liftF.", "1.0.0-RC1") final def liftT[F[_], A, B](fb: F[B])(implicit F: Functor[F]): EitherT[F, A, B] = right(fb) @@ -885,15 +885,19 @@ abstract private[data] class EitherTInstances extends EitherTInstances1 { def monad: Monad[EitherT[M, E, *]] = cats.data.EitherT.catsDataMonadErrorForEitherT def sequential: Nested[P.F, Validated[E, *], *] ~> EitherT[M, E, *] = - λ[Nested[P.F, Validated[E, *], *] ~> EitherT[M, E, *]] { nested => - val mva = P.sequential(nested.value) - EitherT(Functor[M].map(mva)(_.toEither)) + new (Nested[P.F, Validated[E, *], *] ~> EitherT[M, E, *]) { + def apply[A](nested: Nested[P.F, Validated[E, *], A]): EitherT[M, E, A] = { + val mva = P.sequential(nested.value) + EitherT(Functor[M].map(mva)(_.toEither)) + } } def parallel: EitherT[M, E, *] ~> Nested[P.F, Validated[E, *], *] = - λ[EitherT[M, E, *] ~> Nested[P.F, Validated[E, *], *]] { eitherT => - val fea = P.parallel(eitherT.value) - Nested(P.applicative.map(fea)(Validated.fromEither)) + new (EitherT[M, E, *] ~> Nested[P.F, Validated[E, *], *]) { + def apply[A](eitherT: EitherT[M, E, A]): Nested[P.F, Validated[E, *], A] = { + val fea = P.parallel(eitherT.value) + Nested(P.applicative.map(fea)(Validated.fromEither)) + } } } } @@ -946,13 +950,15 @@ abstract private[data] class EitherTInstances1 extends EitherTInstances2 { def monad: Monad[EitherT[M, E, *]] = cats.data.EitherT.catsDataMonadErrorForEitherT def sequential: Nested[M, Validated[E, *], *] ~> EitherT[M, E, *] = - λ[Nested[M, Validated[E, *], *] ~> EitherT[M, E, *]] { nested => - EitherT(Monad[M].map(nested.value)(_.toEither)) + new (Nested[M, Validated[E, *], *] ~> EitherT[M, E, *]) { + def apply[A](nested: Nested[M, Validated[E, *], A]): EitherT[M, E, A] = + EitherT(Monad[M].map(nested.value)(_.toEither)) } def parallel: EitherT[M, E, *] ~> Nested[M, Validated[E, *], *] = - λ[EitherT[M, E, *] ~> Nested[M, Validated[E, *], *]] { eitherT => - Nested(Monad[M].map(eitherT.value)(Validated.fromEither)) + new (EitherT[M, E, *] ~> Nested[M, Validated[E, *], *]) { + def apply[A](eitherT: EitherT[M, E, A]): Nested[M, Validated[E, *], A] = + Nested(Monad[M].map(eitherT.value)(Validated.fromEither)) } } } diff --git a/core/src/main/scala/cats/data/IndexedReaderWriterStateT.scala b/core/src/main/scala/cats/data/IndexedReaderWriterStateT.scala index c0df493935..c45c3df618 100644 --- a/core/src/main/scala/cats/data/IndexedReaderWriterStateT.scala +++ b/core/src/main/scala/cats/data/IndexedReaderWriterStateT.scala @@ -314,7 +314,9 @@ sealed private[data] trait CommonIRWSTConstructors { * }}} */ def liftK[F[_], E, L, S](implicit F: Applicative[F], L: Monoid[L]): F ~> IndexedReaderWriterStateT[F, E, L, S, S, *] = - λ[F ~> IndexedReaderWriterStateT[F, E, L, S, S, *]](IndexedReaderWriterStateT.liftF(_)) + new (F ~> IndexedReaderWriterStateT[F, E, L, S, S, *]) { + def apply[A](a: F[A]): IndexedReaderWriterStateT[F, E, L, S, S, A] = IndexedReaderWriterStateT.liftF(a) + } @deprecated("Use liftF instead", "1.0.0-RC2") def lift[F[_], E, L, S, A](fa: F[A])(implicit F: Applicative[F], diff --git a/core/src/main/scala/cats/data/IndexedStateT.scala b/core/src/main/scala/cats/data/IndexedStateT.scala index c77b39d966..43dac315a1 100644 --- a/core/src/main/scala/cats/data/IndexedStateT.scala +++ b/core/src/main/scala/cats/data/IndexedStateT.scala @@ -185,7 +185,7 @@ private[data] trait CommonStateTConstructors { * }}} */ def liftK[F[_], S](implicit F: Applicative[F]): F ~> IndexedStateT[F, S, S, *] = - λ[F ~> IndexedStateT[F, S, S, *]](IndexedStateT.liftF(_)) + new (F ~> IndexedStateT[F, S, S, *]) { def apply[A](a: F[A]): IndexedStateT[F, S, S, A] = IndexedStateT.liftF(a) } @deprecated("Use liftF instead", "1.0.0-RC2") def lift[F[_], S, A](fa: F[A])(implicit F: Applicative[F]): IndexedStateT[F, S, S, A] = diff --git a/core/src/main/scala/cats/data/IorT.scala b/core/src/main/scala/cats/data/IorT.scala index 7d780db1b9..acf8e92d81 100644 --- a/core/src/main/scala/cats/data/IorT.scala +++ b/core/src/main/scala/cats/data/IorT.scala @@ -425,9 +425,13 @@ abstract private[data] class IorTInstances extends IorTInstances1 { type Dummy // fix to make this one more specific than the catsDataParallelForIorTWithSequentialEffect, see https://github.com/typelevel/cats/pull/2335#issuecomment-408249775 val parallel: IorT[M, E, *] ~> IorT[P.F, E, *] = - λ[IorT[M, E, *] ~> IorT[P.F, E, *]](fm => IorT(P.parallel(fm.value))) + new (IorT[M, E, *] ~> IorT[P.F, E, *]) { + def apply[A](fm: IorT[M, E, A]): IorT[P.F, E, A] = IorT(P.parallel(fm.value)) + } val sequential: IorT[P.F, E, *] ~> IorT[M, E, *] = - λ[IorT[P.F, E, *] ~> IorT[M, E, *]](ff => IorT(P.sequential(ff.value))) + new (IorT[P.F, E, *] ~> IorT[M, E, *]) { + def apply[A](ff: IorT[P.F, E, A]): IorT[M, E, A] = IorT(P.sequential(ff.value)) + } private[this] val FA: Applicative[P.F] = P.applicative private[this] val IorA: Applicative[Ior[E, *]] = Parallel[Ior[E, *], Ior[E, *]].applicative diff --git a/core/src/main/scala/cats/data/Kleisli.scala b/core/src/main/scala/cats/data/Kleisli.scala index b3a141710e..a4953cf0b1 100644 --- a/core/src/main/scala/cats/data/Kleisli.scala +++ b/core/src/main/scala/cats/data/Kleisli.scala @@ -174,7 +174,7 @@ object Kleisli * }}} */ def applyK[F[_], A](a: A): Kleisli[F, A, *] ~> F = - λ[Kleisli[F, A, *] ~> F](_.apply(a)) + new (Kleisli[F, A, *] ~> F) { def apply[B](k: Kleisli[F, A, B]): F[B] = k.apply(a) } } @@ -204,7 +204,7 @@ sealed private[data] trait KleisliFunctions { * }}} */ def liftK[F[_], A]: F ~> Kleisli[F, A, *] = - λ[F ~> Kleisli[F, A, *]](Kleisli.liftF(_)) + new (F ~> Kleisli[F, A, *]) { def apply[B](fb: F[B]): Kleisli[F, A, B] = Kleisli.liftF(fb) } @deprecated("Use liftF instead", "1.0.0-RC2") private[cats] def lift[F[_], A, B](x: F[B]): Kleisli[F, A, B] = @@ -268,7 +268,7 @@ sealed private[data] trait KleisliFunctionsBinCompat { * }}} * */ def liftFunctionK[F[_], G[_], A](f: F ~> G): Kleisli[F, A, *] ~> Kleisli[G, A, *] = - λ[Kleisli[F, A, *] ~> Kleisli[G, A, *]](_.mapK(f)) + new (Kleisli[F, A, *] ~> Kleisli[G, A, *]) { def apply[B](k: Kleisli[F, A, B]): Kleisli[G, A, B] = k.mapK(f) } } sealed private[data] trait KleisliExplicitInstances { @@ -374,10 +374,14 @@ sealed abstract private[data] class KleisliInstances1 extends KleisliInstances2 def monad: Monad[Kleisli[M, A, *]] = catsDataMonadForKleisli def sequential: Kleisli[P.F, A, *] ~> Kleisli[M, A, *] = - λ[Kleisli[P.F, A, *] ~> Kleisli[M, A, *]](_.mapK(P.sequential)) + new (Kleisli[P.F, A, *] ~> Kleisli[M, A, *]) { + def apply[B](k: Kleisli[P.F, A, B]): Kleisli[M, A, B] = k.mapK(P.sequential) + } def parallel: Kleisli[M, A, *] ~> Kleisli[P.F, A, *] = - λ[Kleisli[M, A, *] ~> Kleisli[P.F, A, *]](_.mapK(P.parallel)) + new (Kleisli[M, A, *] ~> Kleisli[P.F, A, *]) { + def apply[B](k: Kleisli[M, A, B]): Kleisli[P.F, A, B] = k.mapK(P.parallel) + } } implicit def catsDataContravariantForKleisli[F[_], C]: Contravariant[Kleisli[F, *, C]] = diff --git a/core/src/main/scala/cats/data/NonEmptyList.scala b/core/src/main/scala/cats/data/NonEmptyList.scala index 99d7566d9c..9a139bc9f2 100644 --- a/core/src/main/scala/cats/data/NonEmptyList.scala +++ b/core/src/main/scala/cats/data/NonEmptyList.scala @@ -668,10 +668,12 @@ sealed abstract private[data] class NonEmptyListInstances extends NonEmptyListIn def apply: Apply[ZipNonEmptyList] = ZipNonEmptyList.catsDataCommutativeApplyForZipNonEmptyList def sequential: ZipNonEmptyList ~> NonEmptyList = - λ[ZipNonEmptyList ~> NonEmptyList](_.value) + new (ZipNonEmptyList ~> NonEmptyList) { def apply[B](nel: ZipNonEmptyList[B]): NonEmptyList[B] = nel.value } def parallel: NonEmptyList ~> ZipNonEmptyList = - λ[NonEmptyList ~> ZipNonEmptyList](nel => new ZipNonEmptyList(nel)) + new (NonEmptyList ~> ZipNonEmptyList) { + def apply[B](nel: NonEmptyList[B]): ZipNonEmptyList[B] = new ZipNonEmptyList(nel) + } } } diff --git a/core/src/main/scala/cats/data/NonEmptyVector.scala b/core/src/main/scala/cats/data/NonEmptyVector.scala index af021ebfce..52d9c8bc8a 100644 --- a/core/src/main/scala/cats/data/NonEmptyVector.scala +++ b/core/src/main/scala/cats/data/NonEmptyVector.scala @@ -478,10 +478,12 @@ sealed abstract private[data] class NonEmptyVectorInstances { def flatMap: FlatMap[NonEmptyVector] = NonEmptyVector.catsDataInstancesForNonEmptyVector def sequential: ZipNonEmptyVector ~> NonEmptyVector = - λ[ZipNonEmptyVector ~> NonEmptyVector](_.value) + new (ZipNonEmptyVector ~> NonEmptyVector) { def apply[A](a: ZipNonEmptyVector[A]): NonEmptyVector[A] = a.value } def parallel: NonEmptyVector ~> ZipNonEmptyVector = - λ[NonEmptyVector ~> ZipNonEmptyVector](nev => new ZipNonEmptyVector(nev)) + new (NonEmptyVector ~> ZipNonEmptyVector) { + def apply[A](nev: NonEmptyVector[A]): ZipNonEmptyVector[A] = new ZipNonEmptyVector(nev) + } } } diff --git a/core/src/main/scala/cats/data/OneAnd.scala b/core/src/main/scala/cats/data/OneAnd.scala index c9d676ec68..cec3f623d8 100644 --- a/core/src/main/scala/cats/data/OneAnd.scala +++ b/core/src/main/scala/cats/data/OneAnd.scala @@ -115,10 +115,14 @@ sealed abstract private[data] class OneAndInstances extends OneAndLowPriority0 { def applicative: Applicative[OneAnd[F0, *]] = catsDataApplicativeForOneAnd(Alternative[F0]) def sequential: OneAnd[F0, *] ~> OneAnd[M, *] = - λ[OneAnd[F0, *] ~> OneAnd[M, *]](ofa => OneAnd(ofa.head, P.sequential(ofa.tail))) + new (OneAnd[F0, *] ~> OneAnd[M, *]) { + def apply[B](ofb: OneAnd[F0, B]): OneAnd[M, B] = OneAnd(ofb.head, P.sequential(ofb.tail)) + } def parallel: OneAnd[M, *] ~> OneAnd[F0, *] = - λ[OneAnd[M, *] ~> OneAnd[F0, *]](ofa => OneAnd(ofa.head, P.parallel(ofa.tail))) + new (OneAnd[M, *] ~> OneAnd[F0, *]) { + def apply[B](ofb: OneAnd[M, B]): OneAnd[F0, B] = OneAnd(ofb.head, P.parallel(ofb.tail)) + } } diff --git a/core/src/main/scala/cats/data/OptionT.scala b/core/src/main/scala/cats/data/OptionT.scala index 24edd3d22e..222e39cca1 100644 --- a/core/src/main/scala/cats/data/OptionT.scala +++ b/core/src/main/scala/cats/data/OptionT.scala @@ -221,7 +221,7 @@ object OptionT extends OptionTInstances { * }}} */ def liftK[F[_]](implicit F: Functor[F]): F ~> OptionT[F, *] = - λ[F ~> OptionT[F, *]](OptionT.liftF(_)) + new (F ~> OptionT[F, *]) { def apply[A](a: F[A]): OptionT[F, A] = OptionT.liftF(a) } /** * Creates a non-empty `OptionT[F, A]` from an `A` value if the given condition is `true`. @@ -241,7 +241,7 @@ object OptionT extends OptionTInstances { * Same as `whenF`, but expressed as a FunctionK for use with mapK. */ def whenK[F[_]](cond: Boolean)(implicit F: Applicative[F]): F ~> OptionT[F, *] = - λ[F ~> OptionT[F, *]](OptionT.whenF(cond)(_)) + new (F ~> OptionT[F, *]) { def apply[A](a: F[A]): OptionT[F, A] = OptionT.whenF(cond)(a) } /** * Creates a non-empty `OptionT[F, A]` from an `A` if the given condition is `false`. @@ -261,7 +261,7 @@ object OptionT extends OptionTInstances { * Same as `unlessF`, but expressed as a FunctionK for use with mapK. */ def unlessK[F[_]](cond: Boolean)(implicit F: Applicative[F]): F ~> OptionT[F, *] = - λ[F ~> OptionT[F, *]](OptionT.unlessF(cond)(_)) + new (F ~> OptionT[F, *]) { def apply[A](a: F[A]): OptionT[F, A] = OptionT.unlessF(cond)(a) } } sealed abstract private[data] class OptionTInstances extends OptionTInstances0 { @@ -324,10 +324,14 @@ sealed abstract private[data] class OptionTInstances extends OptionTInstances0 { def monad: Monad[OptionT[M, *]] = cats.data.OptionT.catsDataMonadErrorMonadForOptionT[M] def sequential: Nested[P.F, Option, *] ~> OptionT[M, *] = - λ[Nested[P.F, Option, *] ~> OptionT[M, *]](nested => OptionT(P.sequential(nested.value))) + new (Nested[P.F, Option, *] ~> OptionT[M, *]) { + def apply[A](nested: Nested[P.F, Option, A]): OptionT[M, A] = OptionT(P.sequential(nested.value)) + } def parallel: OptionT[M, *] ~> Nested[P.F, Option, *] = - λ[OptionT[M, *] ~> Nested[P.F, Option, *]](optT => Nested(P.parallel(optT.value))) + new (OptionT[M, *] ~> Nested[P.F, Option, *]) { + def apply[A](optT: OptionT[M, A]): Nested[P.F, Option, A] = Nested(P.parallel(optT.value)) + } } } diff --git a/core/src/main/scala/cats/data/WriterT.scala b/core/src/main/scala/cats/data/WriterT.scala index e055e03e92..b1fb96cc8c 100644 --- a/core/src/main/scala/cats/data/WriterT.scala +++ b/core/src/main/scala/cats/data/WriterT.scala @@ -339,7 +339,7 @@ object WriterT extends WriterTInstances with WriterTFunctions with WriterTFuncti * }}} */ def liftK[F[_], L](implicit monoidL: Monoid[L], F: Applicative[F]): F ~> WriterT[F, L, *] = - λ[F ~> WriterT[F, L, *]](WriterT.liftF(_)) + new (F ~> WriterT[F, L, *]) { def apply[A](a: F[A]): WriterT[F, L, A] = WriterT.liftF(a) } @deprecated("Use liftF instead", "1.0.0-RC2") def lift[F[_], L, V](fv: F[V])(implicit monoidL: Monoid[L], F: Applicative[F]): WriterT[F, L, V] = @@ -396,10 +396,14 @@ sealed abstract private[data] class WriterTInstances1 extends WriterTInstances2 def monad: Monad[WriterT[M, L, *]] = catsDataMonadForWriterT def sequential: WriterT[P.F, L, *] ~> WriterT[M, L, *] = - λ[WriterT[P.F, L, *] ~> WriterT[M, L, *]](wfl => WriterT(P.sequential(wfl.run))) + new (WriterT[P.F, L, *] ~> WriterT[M, L, *]) { + def apply[A](wfl: WriterT[P.F, L, A]): WriterT[M, L, A] = WriterT(P.sequential(wfl.run)) + } def parallel: WriterT[M, L, *] ~> WriterT[P.F, L, *] = - λ[WriterT[M, L, *] ~> WriterT[P.F, L, *]](wml => WriterT(P.parallel(wml.run))) + new (WriterT[M, L, *] ~> WriterT[P.F, L, *]) { + def apply[A](wml: WriterT[M, L, A]): WriterT[P.F, L, A] = WriterT(P.parallel(wml.run)) + } } implicit def catsDataEqForWriterTId[L: Eq, V: Eq]: Eq[WriterT[Id, L, V]] = diff --git a/core/src/main/scala/cats/instances/either.scala b/core/src/main/scala/cats/instances/either.scala index c7451b272a..aa30e5086d 100644 --- a/core/src/main/scala/cats/instances/either.scala +++ b/core/src/main/scala/cats/instances/either.scala @@ -200,9 +200,9 @@ trait EitherInstances extends cats.kernel.instances.EitherInstances { def monad: Monad[Either[E, *]] = cats.instances.either.catsStdInstancesForEither def sequential: Validated[E, *] ~> Either[E, *] = - λ[Validated[E, *] ~> Either[E, *]](_.toEither) + new (Validated[E, *] ~> Either[E, *]) { def apply[A](a: Validated[E, A]): Either[E, A] = a.toEither } def parallel: Either[E, *] ~> Validated[E, *] = - λ[Either[E, *] ~> Validated[E, *]](_.toValidated) + new (Either[E, *] ~> Validated[E, *]) { def apply[A](a: Either[E, A]): Validated[E, A] = a.toValidated } } } diff --git a/core/src/main/scala/cats/instances/list.scala b/core/src/main/scala/cats/instances/list.scala index d4f15a9ff2..98a64742a9 100644 --- a/core/src/main/scala/cats/instances/list.scala +++ b/core/src/main/scala/cats/instances/list.scala @@ -180,10 +180,10 @@ trait ListInstances extends cats.kernel.instances.ListInstances { def apply: Apply[ZipList] = ZipList.catsDataCommutativeApplyForZipList def sequential: ZipList ~> List = - λ[ZipList ~> List](_.value) + new (ZipList ~> List) { def apply[A](a: ZipList[A]): List[A] = a.value } def parallel: List ~> ZipList = - λ[List ~> ZipList](v => new ZipList(v)) + new (List ~> ZipList) { def apply[A](v: List[A]): ZipList[A] = new ZipList(v) } } } diff --git a/core/src/main/scala/cats/instances/vector.scala b/core/src/main/scala/cats/instances/vector.scala index 31940472f2..869f61b4e6 100644 --- a/core/src/main/scala/cats/instances/vector.scala +++ b/core/src/main/scala/cats/instances/vector.scala @@ -143,10 +143,10 @@ trait VectorInstances extends cats.kernel.instances.VectorInstances { def apply: Apply[ZipVector] = ZipVector.catsDataCommutativeApplyForZipVector def sequential: ZipVector ~> Vector = - λ[ZipVector ~> Vector](_.value) + new (ZipVector ~> Vector) { def apply[A](a: ZipVector[A]): Vector[A] = a.value } def parallel: Vector ~> ZipVector = - λ[Vector ~> ZipVector](v => new ZipVector(v)) + new (Vector ~> ZipVector) { def apply[A](v: Vector[A]): ZipVector[A] = new ZipVector(v) } } } diff --git a/free/src/main/scala/cats/free/Free.scala b/free/src/main/scala/cats/free/Free.scala index ec2ae46608..c95f4fac3a 100644 --- a/free/src/main/scala/cats/free/Free.scala +++ b/free/src/main/scala/cats/free/Free.scala @@ -29,7 +29,7 @@ sealed abstract class Free[S[_], A] extends Product with Serializable { */ final def mapK[T[_]](f: S ~> T): Free[T, A] = foldMap[Free[T, *]] { // this is safe because Free is stack safe - λ[FunctionK[S, Free[T, *]]](fa => Suspend(f(fa))) + new FunctionK[S, Free[T, *]] { def apply[B](sb: S[B]): Free[T, B] = Suspend(f(sb)) } } /** @@ -182,10 +182,10 @@ sealed abstract class Free[S[_], A] extends Product with Serializable { *}}} */ final def inject[G[_]](implicit ev: InjectK[S, G]): Free[G, A] = - mapK(λ[S ~> G](ev.inj(_))) + mapK(new (S ~> G) { def apply[B](sb: S[B]): G[B] = ev.inj(sb) }) final def toFreeT[G[_]: Applicative]: FreeT[S, G, A] = - foldMap[FreeT[S, G, *]](λ[S ~> FreeT[S, G, *]](FreeT.liftF(_))) + foldMap[FreeT[S, G, *]](new (S ~> FreeT[S, G, *]) { def apply[B](sb: S[B]): FreeT[S, G, B] = FreeT.liftF(sb) }) override def toString: String = "Free(...)" @@ -237,7 +237,7 @@ object Free extends FreeInstances { * a FunctionK, suitable for composition, which calls mapK */ def mapK[F[_], G[_]](fk: FunctionK[F, G]): FunctionK[Free[F, *], Free[G, *]] = - λ[FunctionK[Free[F, *], Free[G, *]]](f => f.mapK(fk)) + new FunctionK[Free[F, *], Free[G, *]] { def apply[A](f: Free[F, A]): Free[G, A] = f.mapK(fk) } /** * a FunctionK, suitable for composition, which calls compile @@ -249,7 +249,7 @@ object Free extends FreeInstances { * a FunctionK, suitable for composition, which calls foldMap */ def foldMap[F[_], M[_]: Monad](fk: FunctionK[F, M]): FunctionK[Free[F, *], M] = - λ[FunctionK[Free[F, *], M]](f => f.foldMap(fk)) + new FunctionK[Free[F, *], M] { def apply[A](f: Free[F, A]): M[A] = f.foldMap(fk) } /** * This method is used to defer the application of an InjectK[F, G] diff --git a/free/src/main/scala/cats/free/FreeApplicative.scala b/free/src/main/scala/cats/free/FreeApplicative.scala index 98350d1256..efbfa80977 100644 --- a/free/src/main/scala/cats/free/FreeApplicative.scala +++ b/free/src/main/scala/cats/free/FreeApplicative.scala @@ -141,7 +141,7 @@ sealed abstract class FreeApplicative[F[_], A] extends Product with Serializable */ final def compile[G[_]](f: F ~> G): FA[G, A] = foldMap[FA[G, *]] { - λ[FunctionK[F, FA[G, *]]](fa => lift(f(fa))) + new FunctionK[F, FA[G, *]] { def apply[B](fb: F[B]): FA[G, B] = lift(f(fb)) } } /** @@ -154,13 +154,13 @@ 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 = foldMap[Const[M, *]]( - λ[FunctionK[F, Const[M, *]]](x => Const(f(x))) + new FunctionK[F, Const[M, *]] { def apply[B](fb: F[B]): Const[M, B] = Const(f(fb)) } ).getConst /** Compile this FreeApplicative algebra into a Free algebra. */ final def monad: Free[F, A] = foldMap[Free[F, *]] { - λ[FunctionK[F, Free[F, *]]](fa => Free.liftF(fa)) + new FunctionK[F, Free[F, *]] { def apply[B](fb: F[B]): Free[F, B] = Free.liftF(fb) } } override def toString: String = "FreeApplicative(...)" diff --git a/free/src/main/scala/cats/free/FreeInvariantMonoidal.scala b/free/src/main/scala/cats/free/FreeInvariantMonoidal.scala index 4076eade7b..469da479db 100644 --- a/free/src/main/scala/cats/free/FreeInvariantMonoidal.scala +++ b/free/src/main/scala/cats/free/FreeInvariantMonoidal.scala @@ -28,13 +28,13 @@ sealed abstract class FreeInvariantMonoidal[F[_], A] extends Product with Serial /** Interpret this algebra into another InvariantMonoidal */ final def compile[G[_]](f: FunctionK[F, G]): FA[G, A] = foldMap[FA[G, *]] { - λ[FunctionK[F, FA[G, *]]](fa => lift(f(fa))) + new FunctionK[F, FA[G, *]] { def apply[B](fb: F[B]): FA[G, B] = lift(f(fb)) } } /** Interpret this algebra into a Monoid */ final def analyze[M: Monoid](f: FunctionK[F, λ[α => M]]): M = foldMap[Const[M, *]]( - λ[FunctionK[F, Const[M, *]]](x => Const(f(x))) + new FunctionK[F, Const[M, *]] { def apply[B](fb: F[B]): Const[M, B] = Const(f(fb)) } ).getConst } diff --git a/free/src/main/scala/cats/free/FreeT.scala b/free/src/main/scala/cats/free/FreeT.scala index 7cf0dcc9e6..8a9e9e88ef 100644 --- a/free/src/main/scala/cats/free/FreeT.scala +++ b/free/src/main/scala/cats/free/FreeT.scala @@ -206,10 +206,10 @@ object FreeT extends FreeTInstances { liftF[S, M, FreeT[S, M, A]](value).flatMap(identity) def compile[S[_], T[_], M[_]: Functor](st: FunctionK[S, T]): FunctionK[FreeT[S, M, *], FreeT[T, M, *]] = - λ[FunctionK[FreeT[S, M, *], FreeT[T, M, *]]](f => f.compile(st)) + new FunctionK[FreeT[S, M, *], FreeT[T, M, *]] { def apply[A](f: FreeT[S, M, A]): FreeT[T, M, A] = f.compile(st) } def foldMap[S[_], M[_]: Monad](fk: FunctionK[S, M]): FunctionK[FreeT[S, M, *], M] = - λ[FunctionK[FreeT[S, M, *], M]](f => f.foldMap(fk)) + new FunctionK[FreeT[S, M, *], M] { def apply[A](f: FreeT[S, M, A]): M[A] = f.foldMap(fk) } /** * This method is used to defer the application of an InjectK[F, G] diff --git a/free/src/test/scala/cats/free/CofreeSuite.scala b/free/src/test/scala/cats/free/CofreeSuite.scala index 512c6ffc88..909cdcca77 100644 --- a/free/src/test/scala/cats/free/CofreeSuite.scala +++ b/free/src/test/scala/cats/free/CofreeSuite.scala @@ -83,14 +83,16 @@ class CofreeSuite extends CatsSuite { test("Cofree.mapBranchingRoot") { val unfoldedHundred: CofreeNel[Int] = Cofree.unfold[Option, Int](0)(i => if (i == 100) None else Some(i + 1)) - val withNoneRoot = unfoldedHundred.mapBranchingRoot(λ[Option ~> Option](_ => None)) + val withNoneRoot = unfoldedHundred.mapBranchingRoot(new (Option ~> Option) { + def apply[A](a: Option[A]): Option[A] = None + }) val nelUnfoldedOne: NonEmptyList[Int] = NonEmptyList.one(0) cofNelToNel(withNoneRoot) should ===(nelUnfoldedOne) } val unfoldedHundred: Cofree[Option, Int] = Cofree.unfold[Option, Int](0)(i => if (i == 100) None else Some(i + 1)) test("Cofree.mapBranchingS/T") { - val toList = λ[Option ~> List](_.toList) + val toList = new (Option ~> List) { def apply[A](a: Option[A]): List[A] = a.toList } val toNelS = unfoldedHundred.mapBranchingS(toList) val toNelT = unfoldedHundred.mapBranchingT(toList) val nelUnfoldedOne: NonEmptyList[Int] = NonEmptyList.fromListUnsafe(List.tabulate(101)(identity)) @@ -180,11 +182,19 @@ sealed trait CofreeSuiteInstances { } } - val nelToCofNel = λ[NonEmptyList ~> CofreeNel](fa => Cofree(fa.head, Eval.later(fa.tail.toNel.map(apply)))) + val nelToCofNel = new (NonEmptyList ~> CofreeNel) { + def apply[A](fa: NonEmptyList[A]): CofreeNel[A] = Cofree(fa.head, Eval.later(fa.tail.toNel.map(apply))) + } val cofNelToNel = - λ[CofreeNel ~> NonEmptyList](fa => NonEmptyList(fa.head, fa.tailForced.map(apply(_).toList).getOrElse(Nil))) + new (CofreeNel ~> NonEmptyList) { + def apply[A](fa: CofreeNel[A]): NonEmptyList[A] = + NonEmptyList(fa.head, fa.tailForced.map(apply(_).toList).getOrElse(Nil)) + } val cofRoseTreeToNel = - λ[CofreeRoseTree ~> NonEmptyList](fa => NonEmptyList(fa.head, fa.tailForced.flatMap(apply(_).toList))) + new (CofreeRoseTree ~> NonEmptyList) { + def apply[A](fa: CofreeRoseTree[A]): NonEmptyList[A] = + NonEmptyList(fa.head, fa.tailForced.flatMap(apply(_).toList)) + } } diff --git a/free/src/test/scala/cats/free/ContravariantCoyonedaSuite.scala b/free/src/test/scala/cats/free/ContravariantCoyonedaSuite.scala index c6b96258ab..ba8327da3d 100644 --- a/free/src/test/scala/cats/free/ContravariantCoyonedaSuite.scala +++ b/free/src/test/scala/cats/free/ContravariantCoyonedaSuite.scala @@ -37,7 +37,9 @@ class ContravariantCoyonedaSuite extends CatsSuite { test("mapK and run is same as applying natural trans") { forAll { (b: Boolean) => - val nt = λ[(* => String) ~> (* => Int)](f => s => f(s).length) + val nt = new ((* => String) ~> (* => Int)) { + def apply[A](f: A => String): A => Int = s => f(s).length + } val o = (b: Boolean) => b.toString val c = ContravariantCoyoneda.lift[* => String, Boolean](o) c.mapK[* => Int](nt).run.apply(b) === nt(o).apply(b) diff --git a/free/src/test/scala/cats/free/CoyonedaSuite.scala b/free/src/test/scala/cats/free/CoyonedaSuite.scala index 30004ea51c..a9bc6344fa 100644 --- a/free/src/test/scala/cats/free/CoyonedaSuite.scala +++ b/free/src/test/scala/cats/free/CoyonedaSuite.scala @@ -27,7 +27,7 @@ class CoyonedaSuite extends CatsSuite { } test("mapK and run is same as applying natural trans") { - val nt = λ[FunctionK[Option, List]](_.toList) + val nt = new FunctionK[Option, List] { def apply[A](a: Option[A]): List[A] = a.toList } val o = Option("hello") val c = Coyoneda.lift(o) c.mapK(nt).run should ===(nt(o)) diff --git a/free/src/test/scala/cats/free/FreeApplicativeSuite.scala b/free/src/test/scala/cats/free/FreeApplicativeSuite.scala index b758a55dff..f5b0cbb4f7 100644 --- a/free/src/test/scala/cats/free/FreeApplicativeSuite.scala +++ b/free/src/test/scala/cats/free/FreeApplicativeSuite.scala @@ -54,7 +54,9 @@ class FreeApplicativeSuite extends CatsSuite { test("FreeApplicative#flatCompile") { forAll { (x: FreeApplicative[Option, Int]) => - val nt = λ[FunctionK[Option, FreeApplicative[Option, *]]](FreeApplicative.lift(_)) + val nt = new FunctionK[Option, FreeApplicative[Option, *]] { + def apply[A](a: Option[A]): FreeApplicative[Option, A] = FreeApplicative.lift(a) + } x.foldMap[FreeApplicative[Option, *]](nt).fold should ===(x.flatCompile[Option](nt).fold) } @@ -84,7 +86,7 @@ class FreeApplicativeSuite extends CatsSuite { test("FreeApplicative#analyze") { type G[A] = List[Int] - val countingNT = λ[FunctionK[List, G]](la => List(la.length)) + val countingNT = new FunctionK[List, G] { def apply[A](la: List[A]): G[A] = List(la.length) } val fli1 = FreeApplicative.lift[List, Int](List(1, 3, 5, 7)) fli1.analyze[G[Int]](countingNT) should ===(List(4)) @@ -104,10 +106,11 @@ class FreeApplicativeSuite extends CatsSuite { type Tracked[A] = State[String, A] - val f = λ[FunctionK[Foo, Tracked]] { fa => - State { s0 => - (s0 + fa.toString + ";", fa.getA) - } + val f = new FunctionK[Foo, Tracked] { + def apply[A](fa: Foo[A]): Tracked[A] = + State { s0 => + (s0 + fa.toString + ";", fa.getA) + } } val x: Dsl[Int] = FreeApplicative.lift(Bar(3)) @@ -127,7 +130,7 @@ class FreeApplicativeSuite extends CatsSuite { val z = Apply[Dsl].map2(x, y)((_, _) => ()) - val asString = λ[FunctionK[Id, λ[α => String]]](_.toString) + val asString = new FunctionK[Id, λ[x => String]] { def apply[A](a: A): String = a.toString } z.analyze(asString) should ===("xy") } diff --git a/free/src/test/scala/cats/free/FreeInvariantMonoidalSuite.scala b/free/src/test/scala/cats/free/FreeInvariantMonoidalSuite.scala index 95d8e6bffe..f467cf87f2 100644 --- a/free/src/test/scala/cats/free/FreeInvariantMonoidalSuite.scala +++ b/free/src/test/scala/cats/free/FreeInvariantMonoidalSuite.scala @@ -70,7 +70,7 @@ class FreeInvariantMonoidalSuite extends CatsSuite { test("FreeInvariantMonoidal#analyze") { type G[A] = List[Int] - val countingNT = λ[FunctionK[List, G]](la => List(la.length)) + val countingNT = new FunctionK[List, G] { def apply[A](la: List[A]): G[A] = List(la.length) } val fli1 = FreeInvariantMonoidal.lift[List, Int](List(1, 3, 5, 7)) fli1.analyze[G[Int]](countingNT) should ===(List(4)) diff --git a/free/src/test/scala/cats/free/FreeSuite.scala b/free/src/test/scala/cats/free/FreeSuite.scala index c63ea0f219..232b596e48 100644 --- a/free/src/test/scala/cats/free/FreeSuite.scala +++ b/free/src/test/scala/cats/free/FreeSuite.scala @@ -99,8 +99,10 @@ class FreeSuite extends CatsSuite { z <- if (j < 10000) a(j) else Free.pure[FTestApi, Int](j) } yield z - def runner: FunctionK[FTestApi, Id] = λ[FunctionK[FTestApi, Id]] { - case TB(i) => i + 1 + def runner: FunctionK[FTestApi, Id] = new FunctionK[FTestApi, Id] { + def apply[A](a: FTestApi[A]): A = a match { + case TB(i) => i + 1 + } } } @@ -243,7 +245,7 @@ sealed trait FreeSuiteInstances extends FreeSuiteInstances1 { } sealed trait FreeSuiteInstances1 { - val headOptionU = λ[FunctionK[List, Option]](_.headOption) + val headOptionU = new FunctionK[List, Option] { def apply[A](a: List[A]): Option[A] = a.headOption } private def freeGen[F[_], A](maxDepth: Int)(implicit F: Arbitrary[F[A]], A: Arbitrary[A]): Gen[Free[F, A]] = { val noFlatMapped = Gen.oneOf(A.arbitrary.map(Free.pure[F, A]), F.arbitrary.map(Free.liftF[F, A])) diff --git a/tests/src/test/scala/cats/tests/EitherTSuite.scala b/tests/src/test/scala/cats/tests/EitherTSuite.scala index a22037e38a..0892115220 100644 --- a/tests/src/test/scala/cats/tests/EitherTSuite.scala +++ b/tests/src/test/scala/cats/tests/EitherTSuite.scala @@ -309,7 +309,7 @@ class EitherTSuite extends CatsSuite { } test("mapK consistent with f(value)+pure") { - val f: List ~> Option = λ[List ~> Option](_.headOption) + val f: List ~> Option = new (List ~> Option) { def apply[A](a: List[A]): Option[A] = a.headOption } forAll { (eithert: EitherT[List, String, Int]) => eithert.mapK(f) should ===(EitherT(f(eithert.value))) } diff --git a/tests/src/test/scala/cats/tests/FunctionKSuite.scala b/tests/src/test/scala/cats/tests/FunctionKSuite.scala index 46226d3b08..0fb39cf05a 100644 --- a/tests/src/test/scala/cats/tests/FunctionKSuite.scala +++ b/tests/src/test/scala/cats/tests/FunctionKSuite.scala @@ -9,9 +9,9 @@ import cats.laws.discipline.arbitrary._ class FunctionKSuite extends CatsSuite { - val listToOption = λ[FunctionK[List, Option]](_.headOption) - val listToVector = λ[FunctionK[List, Vector]](_.toVector) - val optionToList = λ[FunctionK[Option, List]](_.toList) + val listToOption = new FunctionK[List, Option] { def apply[A](a: List[A]): Option[A] = a.headOption } + val listToVector = new FunctionK[List, Vector] { def apply[A](a: List[A]): Vector[A] = a.toVector } + val optionToList = new FunctionK[Option, List] { def apply[A](a: Option[A]): List[A] = a.toList } sealed trait Test1Algebra[A] { def v: A @@ -25,8 +25,8 @@ class FunctionKSuite extends CatsSuite { case class Test2[A](v: A) extends Test2Algebra[A] - val Test1FK = λ[FunctionK[Test1Algebra, Id]](_.v) - val Test2FK = λ[FunctionK[Test2Algebra, Id]](_.v) + val Test1FK = new FunctionK[Test1Algebra, Id] { def apply[A](a: Test1Algebra[A]): A = a.v } + val Test2FK = new FunctionK[Test2Algebra, Id] { def apply[A](a: Test2Algebra[A]): A = a.v } test("compose") { forAll { (list: List[Int]) => diff --git a/tests/src/test/scala/cats/tests/IdTSuite.scala b/tests/src/test/scala/cats/tests/IdTSuite.scala index 12a81fb40d..36ad200508 100644 --- a/tests/src/test/scala/cats/tests/IdTSuite.scala +++ b/tests/src/test/scala/cats/tests/IdTSuite.scala @@ -108,7 +108,7 @@ class IdTSuite extends CatsSuite { } test("mapK consistent with f(value)+pure") { - val f: List ~> Option = λ[List ~> Option](_.headOption) + val f: List ~> Option = new (List ~> Option) { def apply[A](a: List[A]): Option[A] = a.headOption } forAll { (idT: IdT[List, Int]) => idT.mapK(f) should ===(IdT(f(idT.value))) } diff --git a/tests/src/test/scala/cats/tests/IndexedReaderWriterStateTSuite.scala b/tests/src/test/scala/cats/tests/IndexedReaderWriterStateTSuite.scala index 61162dac0b..5222e6e382 100644 --- a/tests/src/test/scala/cats/tests/IndexedReaderWriterStateTSuite.scala +++ b/tests/src/test/scala/cats/tests/IndexedReaderWriterStateTSuite.scala @@ -317,7 +317,7 @@ class ReaderWriterStateTSuite extends CatsSuite { } test("ReaderWriterStateT.mapK transforms effect") { - val f: Eval ~> Id = λ[Eval ~> Id](_.value) + val f: Eval ~> Id = new (Eval ~> Id) { def apply[A](a: Eval[A]): A = a.value } forAll { (state: ReaderWriterStateT[Eval, Long, String, String, Int], env: Long, initial: String) => state.mapK(f).runA(env, initial) should ===(state.runA(env, initial).value) } diff --git a/tests/src/test/scala/cats/tests/IndexedStateTSuite.scala b/tests/src/test/scala/cats/tests/IndexedStateTSuite.scala index a55b30b680..c5e6919769 100644 --- a/tests/src/test/scala/cats/tests/IndexedStateTSuite.scala +++ b/tests/src/test/scala/cats/tests/IndexedStateTSuite.scala @@ -247,7 +247,7 @@ class IndexedStateTSuite extends CatsSuite { } test("StateT#mapK transforms effect") { - val f: Eval ~> Id = λ[Eval ~> Id](_.value) + val f: Eval ~> Id = new (Eval ~> Id) { def apply[A](a: Eval[A]): A = a.value } forAll { (state: StateT[Eval, Long, Int], initial: Long) => state.mapK(f).runA(initial) should ===(state.runA(initial).value) } diff --git a/tests/src/test/scala/cats/tests/IorTSuite.scala b/tests/src/test/scala/cats/tests/IorTSuite.scala index ffce078b21..f331b5798a 100644 --- a/tests/src/test/scala/cats/tests/IorTSuite.scala +++ b/tests/src/test/scala/cats/tests/IorTSuite.scala @@ -200,7 +200,7 @@ class IorTSuite extends CatsSuite { } test("mapK consistent with f(value)+pure") { - val f: List ~> Option = λ[List ~> Option](_.headOption) + val f: List ~> Option = new (List ~> Option) { def apply[A](a: List[A]): Option[A] = a.headOption } forAll { (iort: IorT[List, String, Int]) => iort.mapK(f) should ===(IorT(f(iort.value))) } diff --git a/tests/src/test/scala/cats/tests/KleisliSuite.scala b/tests/src/test/scala/cats/tests/KleisliSuite.scala index 410840b9d1..9f1328fe58 100644 --- a/tests/src/test/scala/cats/tests/KleisliSuite.scala +++ b/tests/src/test/scala/cats/tests/KleisliSuite.scala @@ -183,14 +183,14 @@ class KleisliSuite extends CatsSuite { } test("mapK") { - val t: List ~> Option = λ[List ~> Option](_.headOption) + val t: List ~> Option = new (List ~> Option) { def apply[A](a: List[A]): Option[A] = a.headOption } forAll { (f: Kleisli[List, Int, Int], i: Int) => t(f.run(i)) should ===(f.mapK(t).run(i)) } } test("liftFunctionK consistent with mapK") { - val t: List ~> Option = λ[List ~> Option](_.headOption) + val t: List ~> Option = new (List ~> Option) { def apply[A](a: List[A]): Option[A] = a.headOption } forAll { (f: Kleisli[List, Int, Int], i: Int) => (f.mapK(t).run(i)) should ===(Kleisli.liftFunctionK(t)(f).run(i)) } diff --git a/tests/src/test/scala/cats/tests/OptionTSuite.scala b/tests/src/test/scala/cats/tests/OptionTSuite.scala index 02d052e4e7..62f7ef0f7c 100644 --- a/tests/src/test/scala/cats/tests/OptionTSuite.scala +++ b/tests/src/test/scala/cats/tests/OptionTSuite.scala @@ -403,7 +403,7 @@ class OptionTSuite extends CatsSuite { } test("mapK consistent with f(value)+pure") { - val f: List ~> Option = λ[List ~> Option](_.headOption) + val f: List ~> Option = new (List ~> Option) { def apply[A](a: List[A]): Option[A] = a.headOption } forAll { (optiont: OptionT[List, Int]) => optiont.mapK(f) should ===(OptionT(f(optiont.value))) } diff --git a/tests/src/test/scala/cats/tests/WriterTSuite.scala b/tests/src/test/scala/cats/tests/WriterTSuite.scala index dcf1a0e477..f69521e171 100644 --- a/tests/src/test/scala/cats/tests/WriterTSuite.scala +++ b/tests/src/test/scala/cats/tests/WriterTSuite.scala @@ -111,7 +111,7 @@ class WriterTSuite extends CatsSuite { } test("mapK consistent with f(value)+pure") { - val f: List ~> Option = λ[List ~> Option](_.headOption) + val f: List ~> Option = new (List ~> Option) { def apply[A](a: List[A]): Option[A] = a.headOption } forAll { (writert: WriterT[List, String, Int]) => writert.mapK(f) should ===(WriterT(f(writert.run))) }