Mixture of Integer and Float arithmetic without "fromIntegral"?

Tom Pledger Tom.Pledger@peace.com
Wed, 6 Dec 2000 09:27:29 +1300


Christian Lescher writes:
 > When defining expressions with arithmetic operations on a mixture of
 > Integers and Floats (except literals), an explicit conversion by
 > "fromIntegral" for the Integers is necessary, for example: ceiling
 > (fromIntegral n / x)
 > 
 > Is it possible to do the "fromInteger" conversion automatically? What's
 > the best way to do it? (overloading of operators, etc.?)

Hi.

One complication is that some Integer values exceed the greatest
Double value.  In such cases, it's not clear which implementation of
(/) should be used.

It would certainly be nice to have an automatic conversion if, for
example, n were an Int and x were a Float, because those types are
both subsumed by Double.

Regards,
Tom