title: SML: Error: match redundant and Warning:match nonexhaustive
body: <p>I am getting both of these issues for this function:</p>
  
  <pre><code>fun funion([(x:int list,y:bool list)]) =
  let
   fun join(nil,final) = final |
       join(x::xs,final) = join(xs,union(x,final)) |
       join(_,final) = final
  in
   join([(x,y)],(nil,nil))
  end;
  </code></pre>
  
  <p>Here is the error:</p>
  
  <pre><code>sets.sml:30.6-32.27 Error: match redundant
  
  (nil,final) =&gt; ...
  
  (x :: xs,final) =&gt; ...
  
  --&gt;   (_,final) =&gt; ...
  
  sets.sml:28.5-35.4 Warning: match nonexhaustive
  
  (x,y) :: nil =&gt; ...
  </code></pre>
  
  <p>Does anyone know what might be going on here? I also tried join(_) but that did not work either. Not sure what the problem is here.</p>
  
  <p>uncaught exception Error</p>
  
  <p>Edit:</p>
  
  <p>Here is the definition of union:</p>
  
  <pre><code>fun union((w:int list,x:bool list),(y:int list,z:bool list)) =
  let
   fun join((nil,nil),final) = final |
       join((w::ws,x::xs),(intfinal,boolfinal)) = if x andalso elementOf(w,(intfinal,boolfinal))=false then join((ws,xs),(w::intfinal,true::boolfinal)) else join((ws,xs),(intfinal,boolfinal)) |
       join(_,final) = final
  in
   join((w,x),join((y,z),(nil:int list,nil:bool list)))
  end;
  </code></pre>