Re: A sample revised prelude for numeric classes

qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) writes:
Why do you stop at allowing addition on Dollars and not include multiplication by a scalar?
Perhaps because there is no good universal type for (*). Sorry, it would have to have a different symbol.
Is this ubiquitous enough that we should have a *standardized* different symbol? Any candidates?
Having Units as types, with the idea of preventing adding Apples to Oranges, or Dollars to Roubles, is a venerable idea, but is not in widespread use in actual programming languages. Why not?
It does not scale to more general cases. (m/s) / (s) = (m/s^2), so (/) would have to have the type (...) => a -> b -> c, which is not generally usable because of ambiguities. Haskell's classes are not powerful enough to define full algebra of units.
While it may not be in the language, nothing's stopping you from - and some will probably encourage you to - implementing e.g. financial libraries with different data types for different currencies. Which I think is a better way to handle it, since when you want m to be divisible by s is rather application dependent. -kzm -- If I haven't seen further, it is by standing in the footprints of giants

On 12 Feb 2001, Ketil Malde wrote:
qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) writes:
Why do you stop at allowing addition on Dollars and not include multiplication by a scalar?
Perhaps because there is no good universal type for (*). Sorry, it would have to have a different symbol.
Is this ubiquitous enough that we should have a *standardized* different symbol?
I'd think so.
Any candidates?
.* *. [and .*.] ? where the "." is on the side of the scalar -- Jón Fairbairn Jon.Fairbairn@cl.cam.ac.uk 31 Chalmers Road jf@cl.cam.ac.uk Cambridge CB1 3SZ +44 1223 570179 (pm only, please)
participants (2)
-
Jon Fairbairn
-
Ketil Malde