
The NeverEnding story never ends. Good! Le 14/09/2015 04:17, Richard A. O'Keefe a écrit :
Without taking a stand, I note that Clean has one class per "arithmetic" function. This should not be understood too rigidly, we can combine various sectors under one name, e.g.,
class Determinant a | *, -, fromInt a -- as exemplified in the Clean book on FP, page 85. This is a shortcut, but replaces Haskell classes with many members.
I also note that Money / Money -> Number (not Money) and if Money * Money -> something, it certainly isn't Money. Similarly, DateAndTime ± Duration -> DateAndTime, and DateAndTime - DateAndTime -> Duration, but DateAndTime + DateAndTime does not make sense. (DateAndTime and Duration come from Smalltalk.)
I've chosen these examples because they are not "metaphorical" overloadings of the operators. They do obey natural axioms. E.g., now + (now - now) = now, now + (dur*2) = (now+dur)+dur. (Assuming exact numbers underneath.)
Sounds like multi-parameter typeclasses are going to be vital for a restructuring of the numeric classes.
I am afraid that multi-parameter classes will not "save" anything without some precision concerning types themselves. As I say from time to time, physicists live with similar questions for centuries, in the context of physical units. Money*Money is strange. But what about time*time? mass*mass? The gravitational constant G has the dimension m^3 kg^(-1) s^(-2). But only in SI, and related system. You find all possible powers, of dimensional quantities, depending on your choice of *fundamental* unities. I learnt in school the MKS/electrostat system, where an electric charge had the dimension of the square root of force, m^(3/2) kg^(1/2) s^(-1). Later, studying quantum electrodynamics, I assimilated the "truth", that electric charge is just a number, dimensionless. Why? Because physicists have no reluctance to use UNIVERSAL constants as pure numbers, which redefines meters, seconds, etc. : the speed of light is 1. The Planck constant is 1 as well. And the electric charge becomes dimensionless. Cosmologists add G=1, and all dynamical quantities become dimensionless, no more meters, seconds, kilograms. Just numbers. They write formulae, where some quantity is proportional to the logarithm of time. This may disturb even those who accept non-integral powers of length. Is it "cheating", implying log(t/t_0), where the denominator reduces the time unit? What about fractal objects with abominable dimensions, say m^(1.2654132089) ? And such things exist in physics, they are called, for example, anomalous dimensions, measurable. If we decide that there exists universally One Currency to Rule Them All, say, Renminbi, then money + money*money + 1/money + exp(-money) becomes computable. Of course, you will not measure your waist in Planck length units (although for myself, year after year, it becomes less crazy), but all this is not a trivial issue. == This is another reason (the first was torsors) why I don't believe in too simplistic playing with straitjackets, forbidding some operations in the name of "coherence". DateTime vs Duration is another version of the point/vector discussion, or vector vs. affine spaces. Thousands of texts covered all that... Jerzy Karczmarczuk ^