title: How to derive a decoder semiautomatically for a list of some type with Circe?
body: <p>I have an implicit class that decodes server's response into a JSON and latter in the right case class to avoid repeating calls to <code>.as</code> and <code>.getOrElse</code> all around the tests:</p>
  
  <pre class="lang-scala prettyprint-override"><code>implicit class RouteTestResultBody(testResult: RouteTestResult) {
    def body: String = bodyOf(testResult)
    def decodedBody[T](implicit d: Decoder[T]): T =
      decode[Json](body)
        .fold(err =&gt; throw new Exception(s"Body is not a valid JSON: $body"), identity)
        .as[T]
        .getOrElse(throw new Exception(s"JSON doesn't have the right shape: $body"))
  }
  </code></pre>
  
  <p>Of course, it relies on us passing a decoder:</p>
  
  <pre class="lang-scala prettyprint-override"><code>import io.circe.generic.semiauto.deriveDecoder
  
  val result: RouteTestResult = ...
  result.decodedBody(deriveDecoder[SomeType[AnotherType])
  </code></pre>
  
  <p>It works most of the time, but fails when the response is a list:</p>
  
  <pre class="lang-scala prettyprint-override"><code>result.dedoceBody(deriveDecoder[List[SomeType]])
  // throws "JSON doesn't have the right shape"
  </code></pre>
  
  <p>How can I semiautomatically derive a decoder for a list with specific types inside?</p>