title: Composing Futures of a required and optional value
body: <p>Suppose I'm writing a function that receives <code>Future[A]</code> and <code>Future[B]</code> and returns <code>Future[(A, Option[B])]</code> as follows:</p>
  <pre><code>// return the result of &quot;fa&quot; and then
  // either &quot;Some&quot; of the result of &quot;fb&quot; if &quot;fb&quot; has been completed successfully
  // or None if &quot;fb&quot; is still not completed or failed
  // Note: we check `fb` result after `fa` has completed.
  
  def foo(fa: Future[A], fb: Future[B]): Future[(A, Option[B])] = ???
  
  // foo(Future.successful(a), Future.successful(b)) // Future.successful(a, Some(b))
  // foo(Future.successful(a), Future.failed(...))   // Future.successful(a, None)
  // foo(Future.successful(a), Future.never)         // Future.successful(a, None)
  // foo(Future.failed(...),   Future.successful(b)) // Future.failed(...)
  // foo(Future.failed(...),   Future.never)         // Future.failed(...)
  </code></pre>
  <p>I am writing <code>foo</code> like this:</p>
  <pre><code>def foo(fa: Future[A], fb: Future[B]): Future[(A, Option[B])] = for {
    a &lt;- fa
    ob &lt;- if (fb.isCompleted) fb.recover { case NonFatal(_) =&gt; None } else Future.successful(None)
  } yield (a, ob)
  </code></pre>
  <p>This implementation seems working. How would you correct or improve it ?</p>