This is actually not an answer, but maybe a little helps.
I think you're right; it seems that the compiler cannot combine the F[_] types of both parameters (I assume it is a higher type with several possible instances, and not a specific type instance) for the monad type. Compilation works with separate parameter lists, since type unification occurs only in the parameter list. This can be illustrated as follows:
def statyReader[F[_]](implicit r: MonadReader[F, Int], s: MonadState[F, Int]): F[Int] = statyReader2(r, s) def statyReader2[F[_]:Monad](r: MonadReader[F, Int], s: MonadState[F, Int]): F[Int] = for { counter <- s.get secret <- r.ask _ <- s.put(counter + secret) } yield counter Error: ambiguous implicit values: both value s of type scalaz.MonadState[F,Int] and value r of type scalaz.MonadReader[F,Int] match expected type scalaz.Monad[F]
Obviously, as a workaround, you can use two parameter lists to choose which monad you want to use:
def statyReader[F[_]](implicit r: MonadReader[F, Int], s: MonadState[F, Int]): F[Int] = statyReader2(r)(s) def statyReader2[F[_]](r: MonadReader[F, Int])(implicit s: MonadState[F, Int]): F[Int] = for { counter <- s.get secret <- r.ask _ <- s.put(counter + secret) } yield counter
source share