Now, let's talk semantics. Not converting to floating point is precisely the kind of hidden computation that should be avoided, at all costs, in a language. Haskell is efficient and rigorous, and its division operator does floating point conversion. So, no excuses.
The key point in this is that only integer literals get fromInteger applied automatically, so for example
let n=6 :: Integer in n/3
gives a type error since n is not a literal and thus not automatically coerced. (Of course, doing this without the type declaration, let n=6 in n/3
does give 2.0 as result, but it declares n to be a Fractional number, not an Integer.)[^1]: only by default, if you load the rational number library, you can ask for / to compute rational numbers by simply saying the type of result you want: 3/4 :: Ratio Int evaluates to the rational number 3 % 4 (% is Haskell's odd choice of notation for rationals).
# 5/2;;
- : int = 2
# 5 /. 2;;
Error: This expression has type int but an expression was expected of type float
# 5.0 /. float_of_int 2;;
- : float = 2.5