title: check if a tree is complete standard ml
body: <p>I want to make a function in standard ml that checks if a tree is complete or not, the function somehow works, but its giving me the wrong type and a warning of non-exhaustive cases</p>
  
  <p>The tree code:</p>
  
  <pre><code>datatype 'data tree = 
    EMPTY
  | NODE of 'data tree * 'data * 'data tree;
  
  fun isComplete EMPTY = true
    | isComplete (NODE(x, y, z)) = if (x = EMPTY andalso z &lt;&gt; EMPTY) orelse (x &lt;&gt; EMPTY andalso z = EMPTY) then false else true;
  </code></pre>
  
  <p>Now the above function's type is: <code>''a tree -&gt; bool</code> but the required type is <code>'a tree -&gt; bool</code></p>
  
  <p>The warning I'm having is:</p>
  
  <pre><code>stdIn:169.8 Warning: calling polyEqual
  stdIn:169.26 Warning: calling polyEqual
  stdIn:169.45-169.47 Warning: calling polyEqual
  stdIn:169.64-169.66 Warning: calling polyEqual
  stdIn:124.1-169.94 Warning: match nonexhaustive
            NODE (x,y,z) =&gt; ...
  </code></pre>
  
  <p>What is the problem I'm having?</p>
  
  <p>EDIT:</p>
  
  <p>Thanks to Michael, I fixed the code and now it works:</p>
  
  <pre><code>- fun isComplete EMPTY = true
      | isComplete (NODE(EMPTY, _, EMPTY)) = true
      | isComplete (NODE(NODE(x, y, z), _, NODE(a, b, c))) = true
      | isComplete (EMPTY, _, NODE(x, y, z)) = false
      | isComplete (NODE(x, y, z), _, EMPTY) = false;
  </code></pre>