[Haskell-cafe] Thoughts about redesigning "Num" type class
Jerzy Karczmarczuk
jerzy.karczmarczuk at unicaen.fr
Sat Sep 12 09:12:27 UTC 2015
Le 12/09/2015 10:15, Alexey Muranov a écrit :
> the difference of two points in an affine space is a vector, the sum
> of a point of an affine space and a vector is another point.
We can give several similar examples, but it might not be so useful for
the implementation of whatever. In the affine space we can interpolate
between points: p0 + 1/2*(p1-p0) is the middle point. Writing it just as
1/2*(p0+p1) might be considered as an abomination, since you should not
add points... Who should allow the first and forbid the second?
Programming languages is not mathematics. Types are not mathematical
domains. Classes are not categories... Whatever we/you propose, there
will be many unhappy people around. Math is full of subsumptions, whose
automatic implementation might be difficult, inefficient or ambiguous.
If you have an additive group, you have automatically a module over
integers. Sorry, *positive* integers. So, we might second David Thomas,
we should have Rigs (semi-rings). But why a *class*?? And, if you define
such object by hand, you may be accused of introducing redundancies,
that it should be inferred...
And whatever people say, e.g., Wren Romano:
> There are far more objects which have
> addition/multiplication without subtraction than there are objects
> with addition/subtraction without multiplication.
... several simple-minded people (myself included) will find not so
useful and/or clumsy the introduction of specific structures just to
forbid the subtraction. Nobody will fight against these purists, it is
simply a difficult issue.
All this is a can of worms, and physicists live with it already for
centuries
[Time : add please today to yesterday... Subtract works. They were
happy, because there were no computer formalisators around, who could
bother them...].
Please read the *easy* article of John Baez (2009) :
http://math.ucr.edu/home/baez/torsors.html
And then look upon torsors in general, and recognize that is is simply
horrible.
==
All the best.
Jerzy Karczmarczuk
/Caen, France/
More information about the Haskell-Cafe
mailing list