Hi Eric,
> // Variation 2 (works)
> import scalaz.syntax.{ToFunctorOps, ToMonadOps, ToTraverseOps}
> object myimport extends ToFunctorOps with ToMonadOps with ToTraverseOps
> import myimport._
I wouldn't recommend that. As far as I am concerned, those traits are
not supposed to be extended by user code (maybe I'm wrong).
> // Variation 3 (does not work)
> //import scalaz.syntax.monad._
> //import scalaz.syntax.traverse._
> //import scalaz.syntax.std.list._
The problem is that you're both importing `monad` and `traverse` syntax.
Both extend the syntax for functors. Hence, ambiguity.
Here's a minimal example which fails:
import scalaz.Monad
import scalaz.syntax.monad._
import scalaz.syntax.traverse._
trait Foo[M[_]] {
implicit def M: Monad[M]
def mli: M[List[Int]]
def ms = mli.map(_.mkString)
}
// Exiting paste mode, now interpreting.
<console>:16: error: value map is not a member of type parameter
M[List[Int]]
def ms = mli.map(_.mkString)
... and here's how your code can be rewritten to make it work:
import scalaz._
import scalaz.syntax.monad._
import scalaz.std.list._
trait TestB[M[+_]] {
implicit def M: Monad[M]
def testB1: M[List[Int]]
def testB2(i: Int): M[String]
}
trait TestA[M[+_]] {
implicit def M: Monad[M]
val testB: TestB[M]
def testA: M[String] =
for {
b1 <- testB.testB1
b2 <- Traverse[List].sequence(b1.map(b => testB.testB2(b)))
} yield b2.mkString
}
OTOH, I think the best what you can do is to import all syntax.