
23 May
2010
23 May
'10
7:12 a.m.
Daniel Fischer wrote:
There are more rules elsewhere. If you compile with optimisations, GHC turns your realToFrac into double2Float# nicely, so it's okay to use realToFrac. However, without optimisations, no rules fire, so you'll get (fromRational . toRational).
That must be new, because it didn't used to be the case. Also, rewrite rules can be fragile. Not to mention that the (fromRational . toRational) definition is incorrect for converting between Float and Double because Rational cannot properly encode the transfinite values in Float/Double. The robust solution is to use the RealToFrac class from the logfloat package: http://hackage.haskell.org/packages/archive/logfloat/0.12.1/doc/html/Data-Nu... -- Live well, ~wren