title: Scala: checking if an object is Numeric
body: <p>Is it possible for a pattern match to detect if something is a <code>Numeric</code>?  I want to do the following:</p>
  
  <pre><code>class DoubleWrapper(value: Double) {
    override def equals(o: Any): Boolean = o match {
      case o: Numeric =&gt; value == o.toDouble
      case _ =&gt; false
    }
    override def hashCode(): Int = value ##
  }
  </code></pre>
  
  <p>But of course this doesn't really work because <code>Numeric</code> isn't the supertype of things like <code>Int</code> and <code>Double</code>, it's a typeclass.  I also can't do something like <code>def equals[N: Numeric](o: N)</code> because <code>o</code> has to be <code>Any</code> to fit the contract for <code>equals</code>.</p>
  
  <p>So how do I do it without listing out every known <code>Numeric</code> class (including, I guess, user-defined classes I may not even know about)?</p>