title: Encoding recursive data structure into Json with Circe when running on http4s
body: <p>I am building a very simply service, that should return a tree like structure defined through a recursive case class:</p>
  
  <pre><code>case class Node(id: Int, name: String, children: Seq[Node] = Seq())
  </code></pre>
  
  <p>But for some reason I keep getting a following compilation error:</p>
  
  <blockquote>
    <p>Error:(24, 70) could not find implicit value for parameter encoder:
    io.circe.Encoder[Seq[com.ansarada.ds.docviewer.server.Main.Node]]<br>
    implicit val nodesEncoder: EntityEncoder[Seq[Node]] =
    jsonEncoderOf[Seq[Node]] </p>
    
    <p>Error:(24, 70) not enough arguments for
    method jsonEncoderOf: (implicit encoder:
    io.circe.Encoder[Seq[com.ansarada.ds.docviewer.server.Main.Node]])org.http4s.EntityEncoder[Seq[com.ansarada.ds.docviewer.server.Main.Node]].
    Unspecified value parameter encoder.   implicit val nodesEncoder:
    EntityEncoder[Seq[Node]] = jsonEncoderOf[Seq[Node]]</p>
  </blockquote>
  
  <p>The code is compiled, once I remove a children element definition and turn a Node into a flat object:</p>
  
  <pre><code>case class Node(id: Int, name: String)
  </code></pre>
  
  <p>Can anyone help me to define the correct Json encoder for a case with nested children?</p>
  
  <p>Full code:</p>
  
  <pre><code>import org.http4s.circe._
  import org.http4s.dsl._
  import org.http4s.server.blaze.BlazeBuilder
  import org.http4s.server.{Server, ServerApp}
  import org.http4s.{EntityEncoder, HttpService}
  
  import scalaz.concurrent.Task
  
  object Main extends ServerApp {
    import io.circe.generic.auto._
    import io.circe.syntax._
  
    case class Node(id: Int, name: String, children: Seq[Node] = Seq())
  
    def getNodes: Seq[Node] = Seq(
      Node(0, "#One"),
      Node(1, "#Two"),
      Node(2, "#Three")
    )
  
    implicit val nodeEncoder: EntityEncoder[Node] = jsonEncoderOf[Node]
    implicit val nodesEncoder: EntityEncoder[Seq[Node]] = jsonEncoderOf[Seq[Node]]
  
    override def server(args: List[String]): Task[Server] = {
      val nodesService = HttpService {
        case _ @ GET -&gt; Root / "nodes" =&gt;
          Ok(getNodes.asJson)
      }
  
      BlazeBuilder
        .bindHttp(8080, "localhost")
        .mountService(nodesService, "/api")
        .start
    }
  }
  </code></pre>