title: How to iterate all the product types in a coproduct using shapeless?
body: <p>Let's say I have a <a href="https://github.com/milessabin/shapeless/wiki/Feature-overview:-shapeless-2.0.0#coproducts-and-discriminated-unions">coproduct</a> (a sealed trait) such as</p>
  
  <pre><code>sealed trait Traity
  case object Foo extends Traity
  case class Bar() extends Traity
  case class Baz() extends Traity
  </code></pre>
  
  <p>Using shapeless, I can apply polymorphic functions to specific instances but what I'd like to do is to apply a zero-parameter (no-instance) polymorphic function to all the products (i.e. case classes and case objects). I have no idea what the syntax would look like, but something conceptually like:</p>
  
  <pre><code>object mypoly extends Poly1 {
    implicit def traity[T &lt;: Traity] = when[T]( getClass[T].toString )
  }
  
  iterate[Traity](mypoly) // gives List("Foo", "Bar", "Baz")
  </code></pre>
  
  <p>would suit my purposes.</p>