
13 Sep
2015
13 Sep
'15
10:17 p.m.
Without taking a stand, I note that Clean has one class per "arithmetic" function. 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.