```{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FlexibleContexts #-}
(
) where

import Data.Int
import Data.Word
import Prelude hiding ((+), (-), negate, subtract)
import qualified Prelude
import Numeric.Module.Class

infixl 6 -
infixl 7 `times`

class (LeftModule Integer r, RightModule Integer r, AdditiveMonoid r) => AdditiveGroup r where
(-)      :: r -> r -> r
negate   :: r -> r
subtract :: r -> r -> r
times    :: Integral n => n -> r -> r
times y0 x0 = case compare y0 0 of
LT -> f (negate x0) (Prelude.negate y0)
EQ -> zero
GT -> f x0 y0
where
f x y
| even y = f (x + x) (y `quot` 2)
| y == 1 = x
| otherwise = g (x + x) ((y Prelude.- 1) `quot` 2) x
g x y z
| even y = g (x + x) (y `quot` 2) z
| y == 1 = x + z
| otherwise = g (x + x) ((y Prelude.- 1) `quot` 2) (x + z)

negate a = zero - a
a - b  = a + negate b
subtract a b = negate a + b

f - g = \x -> f x - g x
negate f x = negate (f x)
subtract f g x = subtract (f x) (g x)
times n f e = times n (f e)

(-) = (Prelude.-)
negate = Prelude.negate
subtract = Prelude.subtract
times n r = fromIntegral n * r

(-) = (Prelude.-)
negate = Prelude.negate
subtract = Prelude.subtract
times n r = fromIntegral n * r

(-) = (Prelude.-)
negate = Prelude.negate
subtract = Prelude.subtract
times n r = fromIntegral n * r

(-) = (Prelude.-)
negate = Prelude.negate
subtract = Prelude.subtract
times n r = fromIntegral n * r

(-) = (Prelude.-)
negate = Prelude.negate
subtract = Prelude.subtract
times n r = fromIntegral n * r

(-) = (Prelude.-)
negate = Prelude.negate
subtract = Prelude.subtract
times n r = fromIntegral n * r

(-) = (Prelude.-)
negate = Prelude.negate
subtract = Prelude.subtract
times n r = fromIntegral n * r

(-) = (Prelude.-)
negate = Prelude.negate
subtract = Prelude.subtract
times n r = fromIntegral n * r

(-) = (Prelude.-)
negate = Prelude.negate
subtract = Prelude.subtract
times n r = fromIntegral n * r

(-) = (Prelude.-)
negate = Prelude.negate
subtract = Prelude.subtract
times n r = fromIntegral n * r

(-) = (Prelude.-)
negate = Prelude.negate
subtract = Prelude.subtract
times n r = fromIntegral n * r

_ - _   = ()
negate _ = ()
subtract _ _  = ()
times _ _   = ()

negate (a,b) = (negate a, negate b)
(a,b) - (i,j) = (a-i, b-j)
subtract (a,b) (i,j) = (subtract a i, subtract b j)
times n (a,b) = (times n a,times n b)

negate (a,b,c) = (negate a, negate b, negate c)
(a,b,c) - (i,j,k) = (a-i, b-j, c-k)
subtract (a,b,c) (i,j,k) = (subtract a i, subtract b j, subtract c k)
times n (a,b,c) = (times n a,times n b, times n c)