Vote count:
0
I am trying to write a generic function which takes a generic container that implements "++", however I can't seem to get the syntax right.
def pagedRequest[A, C[_] <: Iterable](url: String, accumulator: C[A])(parser: (WSResponse) => C[A]): Future[Either[Result, C[A]]] = {
WS.url(url).get().flatMap { response =>
response.status match {
case OK =>
val data = accumulator ++ parser(response)
(response.json \ "paging" \ "next").asOpt[String] match {
case None => Future.successful(Right(data))
case Some(next) => pagedRequest(next, data)(parser)
}
case _ =>
Future.successful(Left(ProxiedResult(response)))
}
}
}
The type of "data" keeps being Iterable[A], instead of C[A].
asked 37 secs ago
Generic function with type bounds
Aucun commentaire:
Enregistrer un commentaire