You get the same error message if you simply write:
import scalaz._; import Scalaz._ def foo[M[_]:MonadPlus,A](a:A) = a.point[M] foo(1) // <-- error: ambiguous implicit values // both value listInstance ... // and value optionInstance ...
I understand that the compiler is trying to describe the "body" of the bar1 method and not assuming that an instance of MonadPlus[M] (given in the definition of bar ) can be present in the region, it already finds 2 specific instances of MonadPlus[M] (listInstance and optionInstance), which suitable for calling foo . At this point, he simply declares an ambiguity.
Then, in bar2 and bar3 you explicitly specify the instance to use, and in bar4 you specify parameters of type M and Int , which are not ambiguous when calling foo , since it is only hidden in volume with these restrictions implicitly[MonadPlus[M]] .
source share