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

Expand kind-projector's syntax for polymorphic function values #3193

Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions core/src/main/scala-2.12/cats/instances/stream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}

Expand Down
11 changes: 7 additions & 4 deletions core/src/main/scala-2.13+/cats/data/NonEmptyLazyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,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))
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala-2.13+/cats/instances/lazyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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[A](a: ZipLazyList[A]): LazyList[A] = a.value }

def parallel: LazyList ~> ZipLazyList =
λ[LazyList ~> ZipLazyList](v => new ZipLazyList(v))
new (LazyList ~> ZipLazyList) { def apply[A](v: LazyList[A]): ZipLazyList[A] = new ZipLazyList(v) }
}
}
4 changes: 2 additions & 2 deletions core/src/main/scala-2.13+/cats/instances/stream.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}

Expand Down
15 changes: 10 additions & 5 deletions core/src/main/scala/cats/InjectK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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(_))
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions core/src/main/scala/cats/arrow/FunctionK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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
Expand All @@ -44,7 +44,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
Expand All @@ -60,15 +60,15 @@ 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 {

/**
* 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]`.
Expand Down
28 changes: 17 additions & 11 deletions core/src/main/scala/cats/data/EitherT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,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)
Expand Down Expand Up @@ -807,15 +807,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)(_.toValidated))
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)(_.toValidated))
}
}
}
}
Expand Down Expand Up @@ -868,13 +872,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)(_.toValidated))
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)(_.toValidated))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,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],
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/IndexedStateT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,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] =
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/scala/cats/data/IorT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,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
Expand Down
14 changes: 9 additions & 5 deletions core/src/main/scala/cats/data/Kleisli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

}

Expand Down Expand Up @@ -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] =
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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]] =
Expand Down
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/data/NonEmptyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,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)
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions core/src/main/scala/cats/data/NonEmptyVector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,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)
}
}

}
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/scala/cats/data/OneAnd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

}

Expand Down
10 changes: 7 additions & 3 deletions core/src/main/scala/cats/data/OptionT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,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) }
}

sealed abstract private[data] class OptionTInstances extends OptionTInstances0 {
Expand Down Expand Up @@ -285,10 +285,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))
}
}
}

Expand Down
10 changes: 7 additions & 3 deletions core/src/main/scala/cats/data/WriterT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,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] =
Expand Down Expand Up @@ -397,10 +397,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]] =
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/instances/either.scala
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,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 }
}
}
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/instances/list.scala
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,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) }
}
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/instances/vector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,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) }
}
}

Expand Down
Loading