[Haskell-cafe] New OpenGL package: efficient way to convert
daniel.is.fischer at web.de
Thu Mar 4 14:02:27 EST 2010
Am Donnerstag 04 März 2010 19:25:43 schrieb Nick Bowler:
> I agree that the conversions described by the rules are precisely what
> one really wants. However, this doesn't make them valid rules for
> realToFrac, because they do not do the same thing as realToFrac does.
> They break referential transparency by allowing to write functions whose
> behaviour depends on whether or not realToFrac was inlined by the ghc
> (see below for an example).
You're absolutely right, of course. The clean way would be for the modules
defining the newtype wrappers to define and export the desired conversion
functions. Without that, you can only choose between incorrect-but-working-
as-intended rewrite rules and unsafeCoerceButUsedSafelyHere. I don't like
either very much.
> Sorry, I guess I wasn't very clear. I didn't mean to say that
> "fromRational . toRational" is a bad implementation of realToFrac. I
> meant to say that "fromRational . toRational" is not appropriate for
> converting values from one floating point type to another floating point
> type. Corollary: realToFrac is not appropriate for converting values
> from one floating point type to another floating point type.
More information about the Haskell-Cafe