From bdd47fa4bbb6f7bd58976d73262bd49fe8b85bc9 Mon Sep 17 00:00:00 2001 From: Tim Spence Date: Mon, 30 May 2022 13:21:02 +0100 Subject: [PATCH] Require Or instances for givens (#486) --- core/src/main/scala-3/cats/derived/DerivedEmptyK.scala | 4 ++-- core/src/main/scala-3/cats/derived/DerivedFunctor.scala | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/main/scala-3/cats/derived/DerivedEmptyK.scala b/core/src/main/scala-3/cats/derived/DerivedEmptyK.scala index 19f53861..42bcd800 100644 --- a/core/src/main/scala-3/cats/derived/DerivedEmptyK.scala +++ b/core/src/main/scala-3/cats/derived/DerivedEmptyK.scala @@ -30,9 +30,9 @@ object DerivedEmptyK: new EmptyK[[x] =>> F[G[x]]]: def empty[A] = F.unify.empty - given [F[_], G[_]](using NotGiven[Or[F]])(using F: Pure[F], G: Or[G]): DerivedEmptyK[[x] =>> F[G[x]]] = + given [F[_], G[_]](using NotGiven[Or[F]])(using F: DerivedPure.Or[F], G: Or[G]): DerivedEmptyK[[x] =>> F[G[x]]] = new EmptyK[[x] =>> F[G[x]]]: - def empty[A] = F.pure(G.unify.empty) + def empty[A] = F.unify.pure(G.unify.empty) given product[F[_]](using inst: K1.ProductInstances[Or, F]): DerivedEmptyK[F] = new EmptyK[F]: diff --git a/core/src/main/scala-3/cats/derived/DerivedFunctor.scala b/core/src/main/scala-3/cats/derived/DerivedFunctor.scala index 139518ac..07c0ecae 100644 --- a/core/src/main/scala-3/cats/derived/DerivedFunctor.scala +++ b/core/src/main/scala-3/cats/derived/DerivedFunctor.scala @@ -26,8 +26,12 @@ object DerivedFunctor: given [F[_], G[_]](using F: Or[F], G: Or[G]): DerivedFunctor[[x] =>> F[G[x]]] = F.unify.compose(G.unify) - given [F[_], G[_]](using F: Contravariant[F], G: Contravariant[G]): DerivedFunctor[[x] =>> F[G[x]]] = - F.compose(G) + given [F[_], G[_]](using + F: DerivedContravariant.Or[F], + G: DerivedContravariant.Or[G] + ): DerivedFunctor[[x] =>> F[G[x]]] = + given Contravariant[G] = G.unify + F.unify.compose[G] given [F[_]](using inst: => K1.Instances[Or, F]): DerivedFunctor[F] = given K1.Instances[Functor, F] = inst.unify