title: SML Types of rules don't agree and righthand side of clause doesn't agree with function result type
body: <p>I'm trying to write a function in sml that takes  a function and applies it to all elements in a list. If any element returns NONE then the entire function evals to NONE but if any element returns SOME v then that element is added to the accumulator.</p>
  <p>The final return value is SOME of the acculumator. Right now I'm getting two errors.</p>
  <ol>
  <li>hw4.sml:93.21-95.67 Error: types of rules don't agree [tycon mismatch]
  earlier rule(s): 'Z option -&gt; 'Y option
  this rule: 'Z option -&gt; 'X list
  in rule:
  SOME v =&gt; ((all_answers_helper ) xs') v @ acc</li>
  <li>hw4.sml:90.5-95.67 Error: right-hand-side of clause doesn't agree with function result type [tycon mismatch]<br />
  expression:  'Z list -&gt; 'Y list -&gt; 'Y list option
  result type:  'Z list -&gt; 'Y list -&gt; 'Y list
  in declaration:
  all_answers_helper = (fn arg =&gt; (fn  =&gt; ))</li>
  </ol>
  <pre><code>fun all_answers_helper f xs acc = 
          case xs of 
          [] =&gt; SOME acc
          | x::xs' =&gt; case f x of 
                      NONE =&gt; NONE
                      | SOME v =&gt; all_answers_helper f xs' v @ acc
  </code></pre>
  <p>But I have no idea what I'm doing wrong. All help is appreciated!</p>