我有一个简单的方法:
DeleteHash(string key,string cacheSubKey)
{
if (string.IsnullOrEmpty(key))
throw new ArgumentNullException("Some problem here !");
_database.HashDelete(key,cacheSubKey);
}
这是一个http客户端。和def retrieveRepositories(url: String,params: String): IO[HttpResponse] = Hammock.getWithOpts(uri"$url",createOpts).exec[IO]
解码器:
json
现在我要这样称呼此客户:
implicit def decodeResponseEntity(response: HttpResponse): Either[CodecException,List[GitRepository]] = Decoder[List[GitRepository]].decode(response.entity)
但是,def getRepos(organization: String,params: String): F[Either[CodecException,List[GitRepository]]] = for {
res <- retrieveRepositories(organization,params)
result <- Sync[F].delay(decodeResponseEntity(res))
} yield result
行有问题,因为我得到了一个错误:result <- Sync[F].delay(decodeResponseEntity(res))
。当我将Type mismatch. Reguired: IO[B_] but found F[Either[CodecException,List[GitRepository]]]
方法添加到unsafeRunSync()
时,它可以正常工作,但是我应该在最后而不是此处调用此方法。我该如何解决?