here's why it cannot be done:

data TwoByTwoMatrix = TTM Integer Integer Integer Integer

instance Num TwoByTwoMatrix where
  fromInteger i = TTM i 0 0 i
  (TTM a b c d) + (TTM e f g h) = TTM (a+e) (b+f) (c+g) (d+h)
  negate m = (fromInteger (-1)) * m
  (TTM a b c d) * (TTM e f g h) = TTM (b*g+a*e) (a*f+b*h) (d*g+c*e) (c*f+d*h)
It should follow that the above is a (non-abelian) ring, as required (all definitions follow the standard matrix addition/multiplication/addition convensions).

n = (TTM 0 1 0 0)
then: n * (n + 1) = n.
Since n has odd entries, it cannot be divided by 2 (more precisely: we cannot find an m s.t. n * 2 = m).

Best,
Sebastiaan


On Wed, Dec 16, 2020 at 6:14 PM Henning Thielemann <lemming@henning-thielemann.de> wrote:

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)
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.