title: Generic functions in F#
body: <p>I'm still trying to wrap my head around how F# generalizes (or not) functions and types, and there's a case that's bugging me:</p>
  
  <pre><code>let min(a, b) = if a &lt; b then a else b
  
  let add(a, b) = a + b
  
  let minInt = min(3, 4)
  let minFloat = min(3.0, 4.0) // works!
  
  let addInt = add(3, 5)
  let addFloat = add(3.0, 5.0) // error: This expression was expected to have type
                               // int but here has type float
  </code></pre>
  
  <p>Here min has the generic type <code>'a * 'a -&gt; 'a (requires comparison)</code> while add has a concrete type <code>int * int -&gt; int</code>, apparently inferred from its first use in the program. Both are declared and used in the same way, so why the difference in generalization?</p>
  
  <p>I understand that in the case of add, the problem can be side-stepped by declaring the function inline, which causes it to get a generic type definition, i.e. <code>'a * 'b -&gt; 'c (requires member (+))</code>, but that doesn't explain why this is needed in this case and not the other.</p>