title: symmetric equality when making a sanitized string type (using scala.Proxy)
body: <p>I have a scala (2.10.4) application where email addresses are passed around a lot, and I'd like to implement an abstraction that's called at IO to "sanitize" already validated email addresses.</p>
  
  <p>Using <code>scala.Proxy</code> is almost what I want, but I'm running into issues with asymmetric equality.</p>
  
  <pre><code>    class SanitizedEmailAddress(s: String) extends Proxy with Ordered[SanitizedEmailAddress] {
    val self: String = s.toLowerCase.trim
  
    def compare(that: SanitizedEmailAddress) = self compareTo that.self
  }
  
  object SanitizedEmailAddress {
    def apply(s: String) = new SanitizedEmailAddress(s)
    implicit def sanitize(s: String): SanitizedEmailAddress = new SanitizedEmailAddress(s)
    implicit def underlying(e: SanitizedEmailAddress): String = e.self
  }
  </code></pre>
  
  <p>I'd like to have </p>
  
  <pre><code>val sanitizedEmail = SanitizedEmailAddress("Blah@Blah.com")
  val expected = "blah@blah.com"
  assert(sanitizedEmail == expected) // =&gt; true
  assert(expected == sanitizedEmail) // =&gt; true, but this currently returns false :(
  </code></pre>
  
  <p>Or something with similar functionality. Is there any non-cumbersome way to do this? </p>
  
  <pre><code>    assert(sanitizedEmail.self == expected) // =&gt; true (but pretty bad, and someone will forget)
  // can have a custom equality method and use the "pimp-my-lib" pattern on strings, but then we have to remember to use that method every time
  </code></pre>
  
  <p>Thanks for your help.</p>