title: Scala Implicit Search
body: <p>In the Scala with Cats:</p>
  
  <pre><code>import scala.concurrent.{Future, ExecutionContext}
  implicit def futureFunctor
    (implicit ec: ExecutionContext): Functor[Future] = …
  </code></pre>
  
  <blockquote>
    <p>Whenever we summon a Functor for Future , either directly using
    Functor.apply or indirectly via the map extension method, the compiler
    will locate futureFunctor by implicit resolu on and recursively search
    for an ExecutionContext at the call site. This is what the expansion
    might look like:</p>
  </blockquote>
  
  <pre><code>// We write this:
  Functor[Future]
  // The compiler expands to this first:
  Functor[Future](futureFunctor)
  // And then to this:
  Functor[Future](futureFunctor(executionContext))
  </code></pre>
  
  <p>Ok, I try it:</p>
  
  <pre><code>  import scala.concurrent.{Future, ExecutionContext}
    implicit def futureFunctor
    (implicit ec: ExecutionContext): Functor[Future] = new Functor[Future] {
      override def map[A, B](fa: Future[A])(f: A =&gt; B): Future[B] =fa map f
    }
  
    Functor[Future].map(Future.successful(2))(_+1)
  </code></pre>
  
  <p>But get an exception:</p>
  
  <blockquote>
    <p>Error:(29, 10) could not find implicit value for parameter instance:
    cats.Functor[scala.concurrent.Future]<br>
    Functor[Future].map(Future.successful(2))(_+1)</p>
  </blockquote>
  
  <p>Which I would usually fix as:</p>
  
  <pre><code>import cats.instances.future._
  </code></pre>
  
  <p>But the fix does not help. And I must not import it, cause in the scope implicit <code>futureFunctor</code> already defined.</p>
  
  <p>What do I miss?</p>