> > The compiler cannot guess that some primitive Float->Double 
> > function can
> > be used instead of going through Rational.
> 
> If enough inlining is done, then it should be able to deforest the
> intermediate Rational and generate the same code.  But I agree, using RULES
> here is quicker and doesn't rely on some hefty unfoldings.
Unless ghc has gotten incredibly clever I don't believe that.  Look at
the code involved in such a conversion.  It involves, among many other things,
encodeFloat and decodeFloat.  So unless you have taught ghc about how
floating point numbers are represented on all your target machines (I mean,
it doesn't have to be IEEE) you can't really inline these at compile time.
No, this is a perfect example of where you need a RULE.

(BTW, hbc has optimized these conversion since about 6 years ago.)

        -- Lennart

Reply via email to