[Haskell-cafe] "Natural" polymorphism for n*(n+1)/2

Henning Thielemann lemming at henning-thielemann.de
Wed Dec 16 22:48:08 UTC 2020


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.


More information about the Haskell-Cafe mailing list