title: Use shapeless to merge two instances of the same case class
body: <p>I want to merge an update instance of a class into a base instance, choosing the field of the update instance over the base instance if that field is "empty" in the base instance. The example below merges <code>base</code> and <code>update</code>:</p>
  
  <pre><code>case class Foo(a: Option[Int], b: List[Int], c: Option[Int])
  
  val base = Foo(None, Nil, Some(0))
  val update = Foo(Some(3), List(4), None)
  
  merge(base,update) == Foo(Some(3), List(4), Some(0))
  </code></pre>
  
  <p>I've tried something like this:</p>
  
  <pre><code>val g = Generic[Foo]
  val aHList = g.to(base)
  val bHList = g.to(update)
  
  aHList
    .zipWithIndex
    .map({
      case (l: List, i: Int) =&gt; l ++ bHList(i)
      case (o: Option, i: Int) =&gt; if (!bHList(i).nonEmpty) {
        updateHList(i)
      } else {
        o
      }
      case (_, i: Int) =&gt; updateHList(i)
    })
  </code></pre>
  
  <p>But it turns out the generic <code>.to</code> method does not output an <code>HList</code> per say but a <code>Repr</code>. Any idea how I could achieve my goal?</p>
  
  <p>Thank you !</p>