add Bifunctor[λ[(A, B) => F[G[A, B]]]]
instance for F[_]: Functor
and G[_, _]: Bifunctor
#4362
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivated by the desire to
leftMap
on a tuple inside an effect, e.g.If folks aren't comfortable adding this kind of instance, it'd be pretty easy to implement this via a new wrapper class, similar to
Binested
. AFAICTBifunctor[λ[(A, B) => F[G[A, B]]]]
is lawful, but it doesn't infer very well—I don't think you can summon it using the syntax enhancements (e.g.Option("a" -> "b").leftMap(_.length)
doesn't work, butBifunctor[λ[(A, B) => Option[(A, B)]]].leftMap(Option("a" -> "b"))(_.length)
should). Or, we could add both this instance and a new wrapper class.Just for clarity, cats already has
Binested
, but its type parameters are the wrong shape for this use case—it hasF[_, _]
,G[_]
, andH[_]
forF[G[A], H[B]]
, but we needF[_]
andG[_, _]
forF[G[A, B]]
.If we decide not to merge this and want to move forward with a new wrapper, I'll follow up with a new PR.