title: What's the right way to divide two Int values to obtain a Float?
body: <p>I'd like to divide two <code>Int</code> values in Haskell and obtain the result as a <code>Float</code>.  I tried doing it like this:</p>
  
  <pre><code>foo :: Int -&gt; Int -&gt; Float
  foo a b = fromRational $ a % b
  </code></pre>
  
  <p>but GHC (version 6.12.1) tells me "Couldn't match expected type 'Integer' against inferred type 'Int'"  regarding the <code>a</code> in the expression.</p>
  
  <p>I understand why: the <code>fromRational</code> call requires <code>(%)</code> to produce a <code>Ratio Integer</code>, so the operands need to be of type <code>Integer</code> rather than <code>Int</code>.  But the values I'm dividing are nowhere near the <code>Int</code> range limit, so using an arbitrary-precision bignum type seems like overkill.</p>
  
  <p>What's the right way to do this?  Should I just call <code>toInteger</code> on my operands, or is there a better approach (maybe one not involving <code>(%)</code> and ratios) that I don't know about?</p>