title: Define a trait to be extended by case class in scala
body: <p>I have some case classes which have a method <code>tupled</code> defined in its companion object. As it can be seen from the code below in companion objects, it is just code duplication.</p>
  
  <pre><code>case class Book(id: Int, isbn: String, name: String)
  
  object Book {
    def tupled = (Book.apply _).tupled // Duplication
  }
  
  
  case class Author(id: Int, name: String)
  
  object Author {
    def tupled = (Author.apply _).tupled // Duplication
  }
  </code></pre>
  
  <p>From another question (<a href="https://stackoverflow.com/questions/33674602/can-a-scala-self-type-enforce-a-case-class-type">can a scala self type enforce a case class type</a>), it seems like we can not enforce the self-type of a trait to be a case class.</p>
  
  <p>Is there a way to define a trait (say <code>Tupled</code>) that can be applied as following?    </p>
  
  <pre><code>// What would be value of ???
  trait Tupled {
    self: ??? =&gt;
  
    def tupled = (self.apply _).tupled
  }
  
  // Such that I can replace tupled definition with Trait
  object Book extends Tupled {
  }
  </code></pre>