[Haskell-cafe] "Natural" polymorphism for n*(n+1)/2
Tom Smeding
x at tomsmeding.com
Wed Dec 16 23:06:18 UTC 2020
You say 'abs x = x/2', but what's that (/)? For example, what is 'abs' supposed to give when called on (the representation of) the polynomial X^2 + 3X + 2?
Interesting also to think about what the meaning of 'n*(n+1)/2' on polynomials should even be. What is the sum of the numbers (polynomials?) from 1 to X + 1?
- Tom
-------- Original Message --------
On 16 Dec 2020, 23:48, Henning Thielemann < lemming at henning-thielemann.de> wrote:
On Wed, 16 Dec 2020, Tom Smeding wrote:
> I'm not sure what "sound" means if the documentation[1] for Num states that the only reasonable expectation is
> that of a ring.
>
> However, if we are to have laws for signum and abs, then I would expect that 'abs n = n * signum n'. My
> definitions satisfy that law.
What about abs x = x/2 and signum _ = 2?
Would satisfy your law and solve the problem of the original poster.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20201216/215a3f50/attachment.html>
More information about the Haskell-Cafe
mailing list