[Haskell-cafe] Thoughts about redesigning "Num" type class
Richard A. O'Keefe
ok at cs.otago.ac.nz
Mon Sep 14 02:17:27 UTC 2015
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.
More information about the Haskell-Cafe