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

Henning Thielemann lemming at henning-thielemann.de
Wed Dec 16 23:13:29 UTC 2020


On Wed, 16 Dec 2020, Tom Smeding wrote:

> 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?

I meant it this way:

instance (Fractional a) => Num (Polynomial a) where
    abs = fmap (/2)


More information about the Haskell-Cafe mailing list