Skip to content

Commit

Permalink
Require Or instances for givens (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimWSpence authored May 30, 2022
1 parent 21c41a3 commit bdd47fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala-3/cats/derived/DerivedEmptyK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
8 changes: 6 additions & 2 deletions core/src/main/scala-3/cats/derived/DerivedFunctor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bdd47fa

Please sign in to comment.