Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Consider the following code fragment (adapted from

// Using scalaz 6
import scalaz._, Scalaz._

object Example extends App {
  case class Container(i: Int)

  def compute(s: String): State[Container, Int] = state {
    case Container(i) => (Container(i + 1), s.toInt + i)

  val d = List("1", "2", "3")

  type ContainerState[X] = State[Container, X]

  println( d.traverse[ContainerState, Int](compute) ! Container(0) )

I understand what it does on high level. But I wanted to trace what exactly happens during the call to d.traverse at the end. Clearly, List doesn't have traverse, so it must be implicitly converted to another type that does. Even though I spent a considerable amount of time trying to find out, I wasn't very successful. First I found that there is a method in scalaz.Traversable

traverse[F[_], A, B] (f: (A) => F[B], t: T[A])(implicit arg0: Applicative[F]): F[T[B]]

but clearly this is not it (although it's most likely that "my" traverse is implemented using this one). After a lot of searching, I grepped scalaz source codes and I found scalaz.MA's method

traverse[F[_], B] (f: (A) => F[B])(implicit a: Applicative[F], t: Traverse[M]): F[M[B]]

which seems to be very close. Still I'm missing to what List is converted in my example and if it uses MA.traverse or something else.

The question is: What procedure should I follow to find out what exactly is called at d.traverse?

Having even such a simple code that is so hard analyze seems to me like a big problem. Am I missing something very simple?

How should I proceed when I want to understand such code that uses a lot of imported implicits? Is there some way to ask the compiler what implicits it used? Or is there something like Hoogle for Scala so that I can search for a method just by its name?

share|improve this question
up vote 2 down vote accepted

Short answer: use the-Xprint:typer when compiling. I also asked this question here.

As for Hoogle, we have Scalex. You can even use it from sbt via a plugin.

share|improve this answer
Thanks, this is very helpful! – Petr Pudlák Sep 27 '12 at 12:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.