title: Clean way of doing Pattern matching on shapeless Coproduct
body: <p>I found out two ways which I can do pattern matching on a shapeless coproduct. I also googled this subject and found <a href="https://stackoverflow.com/questions/34107849/pattern-matching-with-shapeless-coproduct">this</a></p>
  
  <pre><code>import shapeless._
  
  object ShapelessEx3 extends App {
     case class Red()
     case class Green()
     case class Blue()
     type Colors = Red :+: Green :+: Blue :+: CNil
     val blue = Coproduct[Colors](Blue())
     val green = Coproduct[Colors](Green())
     printColor1(blue)
     printColor2(green)
  
     def printColor1(c: Colors) : Unit = {
        (c.select[Red], c.select[Green], c.select[Blue]) match {
           case (Some(_), None, None) =&gt; println("Color is red")
           case (None, Some(_), None) =&gt; println("Color is green")
           case (None, None, Some(_)) =&gt; println("Color is blue")
           case _ =&gt; println("unknown color")
        }
     }
     def printColor2(c: Colors) : Unit = {
        c match {
           case Inl(Red()) =&gt; println("color is red")
           case Inr(Inl(Green())) =&gt; println("color is green")
           case Inr(Inr(Inl(Blue()))) =&gt; println("color is blue")
           case _ =&gt; println("unknown color")
        }
     }
  }
  </code></pre>
  
  <p>But both the functions are very noisy like <code>case (None, Some(_), None)</code> or <code>Inr(Inr(Inl(Blue())))</code>. How can I so a simple pattern matching like</p>
  
  <pre><code>c match {
    case Red() =&gt;
    case Green() =&gt; 
    case Blue() =&gt; 
  }
  </code></pre>