title: SML: multiple case statements
body: <p>How can I have multiple case statements which do not interleave with each other.
  A toy example for instance:</p>
  
  <pre><code> fun multi_cases(xs) =
       case xs of
         [] =&gt; 5
        | x::ys =&gt; case x of
                      1 =&gt; 2
                     |_ =&gt; 3
        | x::[] =&gt; case x of
                      1 =&gt; 5
                      | _ =&gt; 7
   ;
  
  stdIn:59.17-64.28 Error: types of rules don't agree [overload conflict]
    earlier rule(s): [int ty] -&gt; [int ty]
    this rule: [int ty] list -&gt; [int ty]
    in rule:
      :: (x,nil) =&gt;
        (case x
          of 1 =&gt; 5
           | _ =&gt; 7)
  </code></pre>
  
  <p>The last two case statements are getting mixed up how can I tell SML that they are indeed two independent case statements rather than a continuation/separate branch of case x of 1 => 2 ...</p>
  
  <p>The patterns above as pointed in the answer below have an issue with their generality.</p>