title: Scala value class that supports comparisons and maths operations
body: <p>What is an idomatic way to create a value class in Scala that supports supports comparisons and mathematical operations?  Suppose I have the following value class...</p>
  
  <pre><code>case class Price(value: Double) extends AnyVal
  </code></pre>
  
  <p>I would like to be able to do things like...</p>
  
  <pre><code>val price1 = Price(23.4)
  val price2 = Price(1.0)
  
  price1 &lt;= price2
  price1 + price2
  </code></pre>
  
  <p>...etc for all other comparison and mathematical operators.  One solution is to implement each of the desired methods by hand...</p>
  
  <pre><code>case class Price(value: Double) extends AnyVal {
  
     def &lt;=(that: Price): Boolean = this.value &lt;= that.value
  
  }
  </code></pre>
  
  <p>...but I think there must be a better way. Thoughts?</p>