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

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


On Wed, 16 Dec 2020, Tom Smeding wrote:

> @Douglas:
> What about the ring of polynomials over the integers, i.e. Z[X]? We can certainly define a Num instance for that
> if we set 'signum _ = 1' and 'abs = id'. 'fromInteger' then injects constant polynomials.

I also thought about polynomials, but Num is a Ring plus 'signum' and 
'abs'. Are your definitions ob 'signum' and 'abs' sound? Are there other 
sound definitions that may allow the n*(n+1)/2 magic?


More information about the Haskell-Cafe mailing list