title: SML custom datatype equality without polyEqual
body: <p>I'm trying to write a function to check for type equality, ignoring instance variables (not sure if that's the right terminology for SML). Preferably, this function could operate on multiple datatypes.</p>
  
  <p>So, if I have:</p>
  
  <blockquote>
    <p>datatype D = A | B of int;</p>
  </blockquote>
  
  <p><code>myEqual A A</code>, <code>myEqual (B 1) (B 1)</code>, and <code>myEqual (B 1) (B 2)</code> would all return true, and <code>myEqual A (B 1)</code> would return false.</p>
  
  <p>My first thought was to implement it as something like <code>fun myEqual a b = a = b;</code>. However, this compares the instance variables of both variables, which is not what I want, so <code>myEqual (B 1) (B 2)</code> would return false.</p>
  
  <p>I know that this could be implemented in this case by using pattern matching like</p>
  
  <pre><code>fun myEqual (B _) (B _) = true
    | myEqual A A = true
    | myEqual _ _ = false;
  </code></pre>
  
  <p>But this only works for this specific datatype.</p>
  
  <p>Are there any operations in SML to check only for type equality, but not instance variables?</p>