Revamping the numeric classes
07 Feb 2001 09:39:55 +0100
Brian Boutel <email@example.com> writes:
> * most usage of (+), (-), (*) is on numbers which support all of them.
Yes, but the problem is that the way this is implemented is a nuisance
and a hindrance to those who wants to apply these operators to
different data types. Also, it means functions become less general
than they need to be (or that they need to be parametrized by the
E.g. way back, I wrote a simple differential equation solver. Now,
the same function *could* have been applied to vector functions,
except that I'd have to decide on how to implement all the "Num" stuff
that really didn't fit well. Ideally, a nice class design would
infer, or at least allow me to specify, the mathematical constraints
inherent in an algorithm, and let my implementation work with any data
satisfying those constraints.
Obviously, a good and elegant, yet simple design of type classes is
quite hard. I think it can be done, though.
If I haven't seen further, it is by standing in the footprints of giants