3 ms·
> The new "/", just like Haskell's one, always gives floats, which is good for estimates and consistently and obviously bad for money. Doesn't Haskell's operat
by buckminster 7y ago
> The new "/", just like Haskell's one, always gives floats, which is good for estimates and consistently and obviously bad for money.
Doesn't Haskell's operate on the Fractional type class? Which includes Rational. Or some money type you wrote yourself.
- owl57 7y agoYes. I wrongly remembered (and even checked the out-of-the-box output of ":i Fractional"!) that it doesn't include Rational, but only different flavours of floats. The original point stands: Python's Fraction defines arithmetical operators in the same sane way, and the bespoke money type is about as free as in Haskell to define them in whatever way seems useful, like throwing exceptions on adding dollars to euros. (And also throwing exceptions on adding dollars to generic ints — that one would be a compile-time error in Haskell, which is of course a good thing. Is this not only a good thing but a critical one in financial context?)