[Haskell-cafe] Why no Floating instance for Data.Fixed / Data.Fixed.Binary
Douglas McClean
douglas.mcclean at gmail.com
Mon Apr 13 15:31:30 UTC 2015
I'm wondering why the decision was made not to have a Floating instance for
Data.Fixed.
I understand that -- being a fixed point number type -- it doesn't line up
with the name of the Floating typeclass.
But it also seems that Floating is misnamed, because none of the functions
there really have anything to do with floating point representation. This
is why we still have Floating instances for, say, exact reals or symbolic
numbers, neither of which has a floating point representation.
It seems that the actual criterion for membership in Floating is something
like "has a canonical choice for degree of approximation". Double and Float
are in because we round to the nearest value. Exact reals are in because we
don't have to approximate, symbolic numbers too. Rational is out because
there's no clear choice of how to approximate.
But by this criterion, Data.Fixed should be in. And indeed it would be
useful for it to be in. If I choose to represent values from the real world
by a fixed point approximation instead of a floating point approximation,
shouldn't I still be able to take sines and cosines etc?
Obviously I can fix this by using a newtype. I'm just curious if am I
missing a reason why the current definition is more desirable?
-Doug McClean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150413/d6454d8a/attachment.html>
More information about the Haskell-Cafe
mailing list