title: How to use Either with IO properly?
body: <p>I have <code>AkkaHttp</code> client and <code>cats</code> library. I'd like to escape throwing exception, so I wrote this code:</p>
  
  <pre><code>class AkkaHttpJokeClient(url: String)(implicit system: ActorSystem) extends JokeClient[IO] {
    override def getJoke(): IO[Either[Throwable, Joke]] = {
      implicit val materializer: ActorMaterializer = ActorMaterializer()
      implicit val ec: ExecutionContext = system.dispatcher
  
      IO.fromFuture(IO {
        Http()
          .singleRequest(HttpRequest(uri = url))
          .flatMap(Unmarshal(_).to[String])
          .map(x =&gt; Try{x.parseJson.convertTo[Joke]}.toEither)
        })
    }
  }
  </code></pre>
  
  <p>It works, but I have a few problems with it. The first one is connection problem isn't solved. The second: I think it could be done easier, isn't it? I can't find right methods to do it better.</p>