typelevel / cats

Lightweight, modular, and extensible library for functional programming.
https://typelevel.org/cats/
Other
5.25k stars 1.21k forks source link

Ambiguous implicit values for Functor[Kleisli[F, A, ?]] #2608

Closed mielientiev closed 5 years ago

mielientiev commented 5 years ago

I see the next error in 1.4.0 and 1.5.0-RC0 cats:

 ambiguous implicit values:  both method catsDataApplicativeErrorForKleisli in class KleisliInstances4 of type [F[_], E, A](implicit F0: cats.ApplicativeError[F,E])cats.ApplicativeError[[γ$58$]cats.data.Kleisli[F,A,γ$58$],E]
[error]  and method catsDataFlatMapForKleisli in class KleisliInstances4 of type [F[_], A](implicit FM: cats.FlatMap[F])cats.FlatMap[[γ$59$]cats.data.Kleisli[F,A,γ$59$]]
[error]  match expected type cats.Functor[Kleisli[Result, NodeSeq, A]]
kailuowang commented 5 years ago

This a bug caused by the two methods at the same trait and thus priority. https://github.com/typelevel/cats/blob/master/core/src/main/scala/cats/data/Kleisli.scala#L294-L299

Looks like we can move either up or down. So we will have to insert a new trait into the chain to reduce BC change maybe name it KleisliInstances4a? We can place this new trait in between KleisliInstances4 and KleisliInstances5 and move one of the instances, say catsDataApplicativeErrorForKleisli to it, and to avoid a mima exception we can leave the original one but make it non-implicit.

barambani commented 5 years ago

On it 👍