On Wed, 10 May 2000, Simon Marlow wrote:
> > {-# RULES
> > "realToFrac/Float->Double" realToFrac = floatToDouble
> > "realToFrac/Double->Float" realToFrac = doubleToFloat #-}
> Is this 4.06? The current prelude contains
>
> {-# SPECIALIZE realToFrac ::
> which should provide for all your float-converting needs :-)
It only provides specialization of this definition, i.e. fromRational and
toRational dispatching is done at compile time (which, I hope, is done
automatically anyway at least in cases where such function gets inlined).
The compiler cannot guess that some primitive Float->Double function can
be used instead of going through Rational.
AFAIR integral types do have {-#RULES#-} for conversions between each pair
of them, including Int16/Word64/etc. I'm not sure about Int->Double etc.
(both fromIntegral and realToFrac can be used here!).
--
Marcin 'Qrczak' Kowalczyk