[Pkg-haskell-commits] darcs: haskell-maths: patches/add-Eq-Constraints: Add Eq constraints where necessary

Joachim Breitner mail at joachim-breitner.de
Sat Feb 4 11:54:44 UTC 2012


Sat Feb  4 11:52:07 UTC 2012  Joachim Breitner <mail at joachim-breitner.de>
  * patches/add-Eq-Constraints: Add Eq constraints where necessary
  Ignore-this: 78c30414ba71a60bac4cd2f103d66778

    M ./changelog -2 +3
    A ./patches/
    A ./patches/add-Eq-Constraints
    A ./patches/series

Sat Feb  4 11:52:07 UTC 2012  Joachim Breitner <mail at joachim-breitner.de>
  * patches/add-Eq-Constraints: Add Eq constraints where necessary
  Ignore-this: 78c30414ba71a60bac4cd2f103d66778
diff -rN -u old-haskell-maths//changelog new-haskell-maths//changelog
--- old-haskell-maths//changelog	2012-02-04 11:54:44.841746098 +0000
+++ new-haskell-maths//changelog	2012-02-04 11:54:44.849746460 +0000
@@ -1,8 +1,9 @@
-haskell-maths (0.4.1-2) UNRELEASED; urgency=low
+haskell-maths (0.4.1-2) unstable; urgency=low
 
   * Depend on libghc-random-dev, as it was split out from GHC 
+  * patches/add-Eq-Constraints: Add Eq constraints where necessary
 
- -- Joachim Breitner <nomeata at debian.org>  Sat, 04 Feb 2012 12:17:29 +0100
+ -- Joachim Breitner <nomeata at debian.org>  Sat, 04 Feb 2012 12:17:46 +0100
 
 haskell-maths (0.4.1-1) unstable; urgency=low
 
diff -rN -u old-haskell-maths//patches/add-Eq-Constraints new-haskell-maths//patches/add-Eq-Constraints
--- old-haskell-maths//patches/add-Eq-Constraints	1970-01-01 00:00:00.000000000 +0000
+++ new-haskell-maths//patches/add-Eq-Constraints	2012-02-04 11:54:44.853750337 +0000
@@ -0,0 +1,1260 @@
+Description: Add Eq Constraints
+ to make it compile with GHC 7.4.1
+Author: Joachim Breitner <nomeata at debian.org>
+
+Index: haskell-maths-0.4.1/Math/Algebras/VectorSpace.hs
+===================================================================
+--- haskell-maths-0.4.1.orig/Math/Algebras/VectorSpace.hs	2012-02-04 12:19:38.000000000 +0100
++++ haskell-maths-0.4.1/Math/Algebras/VectorSpace.hs	2012-02-04 12:22:45.000000000 +0100
+@@ -19,7 +19,7 @@
+ -- Elements of Vect k b consist of k-linear combinations of elements of b.
+ newtype Vect k b = V [(b,k)] deriving (Eq,Ord)
+ 
+-instance (Num k, Show b) => Show (Vect k b) where
++instance (Show k, Eq k, Num k, Show b) => Show (Vect k b) where
+     show (V []) = "0"
+     show (V ts) = concatWithPlus $ map showTerm ts
+         where showTerm (b,x) | show b == "1" = show x
+@@ -52,11 +52,11 @@
+ zerov = V []
+ 
+ -- |Addition of vectors
+-add :: (Ord b, Num k) => Vect k b -> Vect k b -> Vect k b
++add :: (Ord b, Eq k, Num k) => Vect k b -> Vect k b -> Vect k b
+ add (V ts) (V us) = V $ addmerge ts us
+ 
+ -- |Addition of vectors (same as add)
+-(<+>) :: (Ord b, Num k) => Vect k b -> Vect k b -> Vect k b
++(<+>) :: (Ord b, Eq k, Num k) => Vect k b -> Vect k b -> Vect k b
+ (<+>) = add
+ 
+ addmerge ((a,x):ts) ((b,y):us) =
+@@ -68,33 +68,33 @@
+ addmerge [] us = us
+ 
+ -- |Sum of a list of vectors
+-sumv :: (Ord b, Num k) => [Vect k b] -> Vect k b
++sumv :: (Ord b, Eq k, Num k) => [Vect k b] -> Vect k b
+ sumv = foldl (<+>) zerov
+ 
+ -- |Negation of vector
+-neg :: (Num k) => Vect k b -> Vect k b
++neg :: (Eq k, Num k) => Vect k b -> Vect k b
+ neg (V ts) = V $ map (\(b,x) -> (b,-x)) ts
+ 
+ -- |Subtraction of vectors
+-(<->) :: (Ord b, Num k) => Vect k b -> Vect k b -> Vect k b
++(<->) :: (Ord b, Eq k, Num k) => Vect k b -> Vect k b -> Vect k b
+ (<->) u v = u <+> neg v
+ 
+ -- |Scalar multiplication (on the left)
+-smultL :: (Num k) => k -> Vect k b -> Vect k b
++smultL :: (Eq k, Num k) => k -> Vect k b -> Vect k b
+ smultL 0 _ = zero -- V []
+ smultL k (V ts) = V [(ei,k*xi) | (ei,xi) <- ts]
+ 
+ -- |Same as smultL. Mnemonic is \"multiply through (from the left)\"
+-(*>) :: (Num k) => k -> Vect k b -> Vect k b
++(*>) :: (Eq k, Num k) => k -> Vect k b -> Vect k b
+ (*>) = smultL
+ 
+ -- |Scalar multiplication on the right
+-smultR :: (Num k) => Vect k b -> k -> Vect k b
++smultR :: (Eq k, Num k) => Vect k b -> k -> Vect k b
+ smultR _ 0 = zero -- V []
+ smultR (V ts) k = V [(ei,xi*k) | (ei,xi) <- ts]
+ 
+ -- |Same as smultR. Mnemonic is \"multiply through (from the right)\"
+-(<*) :: (Num k) => Vect k b -> k -> Vect k b
++(<*) :: (Eq k, Num k) => Vect k b -> k -> Vect k b
+ (<*) = smultR
+ 
+ -- same as return
+@@ -107,7 +107,7 @@
+ 
+ -- |Convert an element of Vect k b into normal form. Normal form consists in having the basis elements in ascending order,
+ -- with no duplicates, and all coefficients non-zero
+-nf :: (Ord b, Num k) => Vect k b -> Vect k b
++nf :: (Ord b, Eq k, Num k) => Vect k b -> Vect k b
+ nf (V ts) = V $ nf' $ L.sortBy compareFst ts where
+     nf' ((b1,x1):(b2,x2):ts) =
+         case compare b1 b2 of
+@@ -135,7 +135,7 @@
+ --
+ -- If we have A = Vect k a, B = Vect k b, and f :: a -> Vect k b is a function from the basis elements of A into B,
+ -- then @linear f@ is the linear map that this defines by linearity.
+-linear :: (Ord b, Num k) => (a -> Vect k b) -> Vect k a -> Vect k b
++linear :: (Ord b, Eq k, Num k) => (a -> Vect k b) -> Vect k a -> Vect k b
+ linear f v = nf $ v >>= f
+ 
+ newtype EBasis = E Int deriving (Eq,Ord)
+@@ -154,7 +154,7 @@
+ -- but in the code, we need this if we want to be able to put k as one side of a tensor product.
+ type Trivial k = Vect k ()
+ 
+-wrap :: Num k => k -> Vect k ()
++wrap :: (Eq k, Num k) => k -> Vect k ()
+ wrap 0 = zero
+ wrap x = V [( (),x)]
+ 
+Index: haskell-maths-0.4.1/Math/Algebras/TensorProduct.hs
+===================================================================
+--- haskell-maths-0.4.1.orig/Math/Algebras/TensorProduct.hs	2011-11-10 22:38:12.000000000 +0100
++++ haskell-maths-0.4.1/Math/Algebras/TensorProduct.hs	2012-02-04 12:25:06.000000000 +0100
+@@ -27,7 +27,7 @@
+ 
+ -- |The coproduct of two linear functions (with the same target).
+ -- Satisfies the universal property that f == coprodf f g . i1 and g == coprodf f g . i2
+-coprodf :: (Num k, Ord t) =>
++coprodf :: (Eq k, Num k, Ord t) =>
+     (Vect k a -> Vect k t) -> (Vect k b -> Vect k t) -> Vect k (DSum a b) -> Vect k t
+ coprodf f g = linear fg' where
+     fg' (Left a) = f (return a)
+@@ -35,33 +35,33 @@
+ 
+ 
+ -- |Projection onto left summand from direct sum
+-p1 :: (Num k, Ord a) => Vect k (DSum a b) -> Vect k a
++p1 :: (Eq k, Num k, Ord a) => Vect k (DSum a b) -> Vect k a
+ p1 = linear p1' where
+     p1' (Left a) = return a
+     p1' (Right b) = zero
+ 
+ -- |Projection onto right summand from direct sum
+-p2 :: (Num k, Ord b) => Vect k (DSum a b) -> Vect k b
++p2 :: (Eq k, Num k, Ord b) => Vect k (DSum a b) -> Vect k b
+ p2 = linear p2' where
+     p2' (Left a) = zero
+     p2' (Right b) = return b
+ 
+ -- |The product of two linear functions (with the same source).
+ -- Satisfies the universal property that f == p1 . prodf f g and g == p2 . prodf f g
+-prodf :: (Num k, Ord a, Ord b) =>
++prodf :: (Eq k, Num k, Ord a, Ord b) =>
+     (Vect k s -> Vect k a) -> (Vect k s -> Vect k b) -> Vect k s -> Vect k (DSum a b)
+ prodf f g = linear fg' where
+     fg' b = fmap Left (f $ return b) <+> fmap Right (g $ return b)
+ 
+ 
+ -- |The direct sum of two vector space elements
+-dsume :: (Num k, Ord a, Ord b) => Vect k a -> Vect k b -> Vect k (DSum a b)
++dsume :: (Eq k, Num k, Ord a, Ord b) => Vect k a -> Vect k b -> Vect k (DSum a b)
+ -- dsume x y = fmap Left x <+> fmap Right y
+ dsume x y = i1 x <+> i2 y
+ 
+ -- |The direct sum of two linear functions.
+ -- Satisfies the universal property that f == p1 . dsumf f g . i1 and g == p2 . dsumf f g . i2
+-dsumf :: (Num k, Ord a, Ord b, Ord a', Ord b') => 
++dsumf :: (Eq k, Num k, Ord a, Ord b, Ord a', Ord b') => 
+     (Vect k a -> Vect k a') -> (Vect k b -> Vect k b') -> Vect k (DSum a b) -> Vect k (DSum a' b')
+ dsumf f g ab = (i1 . f . p1) ab <+> (i2 . g . p2) ab
+ 
+@@ -80,7 +80,7 @@
+ 
+ -- Implicit assumption - f and g are linear
+ -- |The tensor product of two linear functions
+-tf :: (Num k, Ord a', Ord b') => (Vect k a -> Vect k a') -> (Vect k b -> Vect k b')
++tf :: (Eq k, Num k, Ord a', Ord b') => (Vect k a -> Vect k a') -> (Vect k b -> Vect k b')
+    -> Vect k (Tensor a b) -> Vect k (Tensor a' b')
+ tf f g (V ts) = sum [x *> te (f $ return a) (g $ return b) | ((a,b), x) <- ts]
+     where sum = foldl add zero -- (V [])
+@@ -107,16 +107,16 @@
+ unitOutR :: Vect k (Tensor a ()) -> Vect k a
+ unitOutR = fmap ( \(a,()) -> a )
+ 
+-twist :: (Num k, Ord a, Ord b) => Vect k (Tensor a b) -> Vect k (Tensor b a)
++twist :: (Eq k, Num k, Ord a, Ord b) => Vect k (Tensor a b) -> Vect k (Tensor b a)
+ twist v = nf $ fmap ( \(a,b) -> (b,a) ) v
+ -- note the nf call, as f is not order-preserving
+ 
+ 
+-distrL :: (Num k, Ord a, Ord b, Ord c)
++distrL :: (Eq k, Num k, Ord a, Ord b, Ord c)
+     => Vect k (Tensor a (DSum b c)) -> Vect k (DSum (Tensor a b) (Tensor a c))
+ distrL v = nf $ fmap (\(a,bc) -> case bc of Left b -> Left (a,b); Right c -> Right (a,c)) v
+ 
+-undistrL :: (Num k, Ord a, Ord b, Ord c)
++undistrL :: (Eq k, Num k, Ord a, Ord b, Ord c)
+     => Vect k (DSum (Tensor a b) (Tensor a c)) -> Vect k (Tensor a (DSum b c))
+ undistrL v = nf $ fmap ( \abc -> case abc of Left (a,b) -> (a,Left b); Right (a,c) -> (a,Right c) ) v
+ 
+@@ -132,11 +132,11 @@
+ -- Left (e1,e2)
+ 
+ 
+-ev :: (Num k, Ord b) => Vect k (Tensor (Dual b) b) -> k
++ev :: (Eq k, Num k, Ord b) => Vect k (Tensor (Dual b) b) -> k
+ ev = unwrap . linear (\(Dual bi, bj) -> delta bi bj *> return ())
+ -- slightly cheating, as delta i j is meant to compare indices, not the basis elements themselves
+ 
+ delta i j = if i == j then 1 else 0
+ 
+-reify :: (Num k, Ord b) => Vect k (Dual b) -> (Vect k b -> k)
++reify :: (Eq k, Num k, Ord b) => Vect k (Dual b) -> (Vect k b -> k)
+ reify f x = ev (f `te` x)
+Index: haskell-maths-0.4.1/Math/Algebras/Structures.hs
+===================================================================
+--- haskell-maths-0.4.1.orig/Math/Algebras/Structures.hs	2011-11-10 22:38:12.000000000 +0100
++++ haskell-maths-0.4.1/Math/Algebras/Structures.hs	2012-02-04 12:26:59.000000000 +0100
+@@ -43,7 +43,7 @@
+     antipode :: Vect k b -> Vect k b
+ 
+ 
+-instance (Num k, Eq b, Ord b, Show b, Algebra k b) => Num (Vect k b) where
++instance (Eq k, Num k, Eq b, Ord b, Show b, Algebra k b) => Num (Vect k b) where
+     x+y = x <+> y
+     negate x = neg x
+     -- negate (V ts) = V $ map (\(b,x) -> (b, negate x)) ts
+@@ -66,7 +66,7 @@
+ -}
+ 
+ 
+-instance Num k => Algebra k () where
++instance (Eq k, Num k) => Algebra k () where
+     unit = wrap
+     -- unit 0 = zero -- V []
+     -- unit x = V [( (),x)]
+@@ -74,7 +74,7 @@
+     -- mult (V [( ((),()), x)]) = V [( (),x)]
+     -- mult (V []) = zerov
+ 
+-instance Num k => Coalgebra k () where
++instance (Eq k, Num k) => Coalgebra k () where
+     counit = unwrap
+     -- counit (V []) = 0
+     -- counit (V [( (),x)]) = x
+@@ -82,10 +82,10 @@
+     -- comult (V [( (),x)]) = V [( ((),()), x)]
+     -- comult (V []) = zerov
+ 
+-unit' :: (Num k, Algebra k b) => Trivial k -> Vect k b
++unit' :: (Eq k, Num k, Algebra k b) => Trivial k -> Vect k b
+ unit' = unit . unwrap -- where unwrap = counit :: Num k => Trivial k -> k
+ 
+-counit' :: (Num k, Coalgebra k b) => Vect k b -> Trivial k
++counit' :: (Eq k, Num k, Coalgebra k b) => Vect k b -> Trivial k
+ counit' = wrap . counit -- where wrap = unit :: Num k => k -> Trivial k
+ 
+ -- unit' and counit' enable us to form tensors of these functions
+@@ -94,7 +94,7 @@
+ -- Kassel p4
+ -- |The direct sum of k-algebras can itself be given the structure of a k-algebra.
+ -- This is the product object in the category of k-algebras.
+-instance (Num k, Ord a, Ord b, Algebra k a, Algebra k b) => Algebra k (DSum a b) where
++instance (Eq k, Num k, Ord a, Ord b, Algebra k a, Algebra k b) => Algebra k (DSum a b) where
+     unit k = i1 (unit k) <+> i2 (unit k)
+     -- unit == (i1 . unit) <<+>> (i2 . unit)
+     mult = linear mult'
+@@ -108,7 +108,7 @@
+ 
+ -- |The direct sum of k-coalgebras can itself be given the structure of a k-coalgebra.
+ -- This is the coproduct object in the category of k-coalgebras.
+-instance (Num k, Ord a, Ord b, Coalgebra k a, Coalgebra k b) => Coalgebra k (DSum a b) where
++instance (Eq k, Num k, Ord a, Ord b, Coalgebra k a, Coalgebra k b) => Coalgebra k (DSum a b) where
+     counit = unwrap . linear counit'
+         where counit' (Left a) = (wrap . counit) (return a)
+               counit' (Right b) = (wrap . counit) (return b)
+@@ -123,7 +123,7 @@
+ 
+ -- Kassel p32
+ -- |The tensor product of k-algebras can itself be given the structure of a k-algebra
+-instance (Num k, Ord a, Ord b, Algebra k a, Algebra k b) => Algebra k (Tensor a b) where
++instance (Eq k, Num k, Ord a, Ord b, Algebra k a, Algebra k b) => Algebra k (Tensor a b) where
+     -- unit 0 = V []
+     unit x = x *> (unit 1 `te` unit 1)
+     mult = linear m where
+@@ -131,7 +131,7 @@
+ 
+ -- Kassel p42
+ -- |The tensor product of k-coalgebras can itself be given the structure of a k-coalgebra
+-instance (Num k, Ord a, Ord b, Coalgebra k a, Coalgebra k b) => Coalgebra k (Tensor a b) where
++instance (Eq k, Num k, Ord a, Ord b, Coalgebra k a, Coalgebra k b) => Coalgebra k (Tensor a b) where
+     counit = counit . (counit' `tf` counit')
+     -- counit = counit . linear (\(T x y) -> counit' (return x) * counit' (return y))
+     comult = assocL . (id `tf` assocR) . (id `tf` (twist `tf` id))
+@@ -139,20 +139,20 @@
+ 
+ 
+ -- The set coalgebra - can be defined on any set
+-instance Num k => Coalgebra k EBasis where
++instance (Eq k, Num k) => Coalgebra k EBasis where
+     counit (V ts) = sum [x | (ei,x) <- ts]  -- trace
+     comult = fmap ( \ei -> (ei,ei) )        -- diagonal
+ 
+ newtype SetCoalgebra b = SC b deriving (Eq,Ord,Show)
+ 
+-instance Num k => Coalgebra k (SetCoalgebra b) where
++instance (Eq k, Num k) => Coalgebra k (SetCoalgebra b) where
+     counit (V ts) = sum [x | (m,x) <- ts]  -- trace
+     comult = fmap ( \m -> (m,m) )          -- diagonal
+ 
+ 
+ newtype MonoidCoalgebra m = MC m deriving (Eq,Ord,Show)
+ 
+-instance (Num k, Ord m, Mon m) => Coalgebra k (MonoidCoalgebra m) where
++instance (Eq k, Num k, Ord m, Mon m) => Coalgebra k (MonoidCoalgebra m) where
+     counit (V ts) = sum [if m == MC munit then x else 0 | (m,x) <- ts]
+     comult = linear cm
+         where cm m = if m == MC munit then return (m,m) else return (m, MC munit) <+> return (MC munit, m)
+@@ -184,13 +184,13 @@
+ 
+ -- Kassel p57-8
+ 
+-instance (Num k, Ord a, Ord u, Ord v, Algebra k a, Module k a u, Module k a v)
++instance (Eq k, Num k, Ord a, Ord u, Ord v, Algebra k a, Module k a u, Module k a v)
+          => Module k (Tensor a a) (Tensor u v) where
+     -- action x = nf $ x >>= action'
+     action = linear action'
+         where action' ((a,a'), (u,v)) = (action $ return (a,u)) `te` (action $ return (a',v))
+ 
+-instance (Num k, Ord a, Ord u, Ord v, Bialgebra k a, Module k a u, Module k a v)
++instance (Eq k, Num k, Ord a, Ord u, Ord v, Bialgebra k a, Module k a u, Module k a v)
+          => Module k a (Tensor u v) where
+     -- action x = nf $ x >>= action'
+     action = linear action'
+@@ -200,7 +200,7 @@
+ -- On the other hand, if a == Tensor u v, then we have overlapping instance with the earlier instance
+ 
+ -- Kassel p63
+-instance (Num k, Ord a, Ord m, Ord n, Bialgebra k a, Comodule k a m, Comodule k a n)
++instance (Eq k, Num k, Ord a, Ord m, Ord n, Bialgebra k a, Comodule k a m, Comodule k a n)
+          => Comodule k a (Tensor m n) where
+     coaction = (mult `tf` id) . twistm . (coaction `tf` coaction)
+         where twistm x = nf $ fmap ( \((h,m), (h',n)) -> ((h,h'), (m,n)) ) x
+Index: haskell-maths-0.4.1/Math/Algebra/Field/Extension.hs
+===================================================================
+--- haskell-maths-0.4.1.orig/Math/Algebra/Field/Extension.hs	2011-11-10 22:38:12.000000000 +0100
++++ haskell-maths-0.4.1/Math/Algebra/Field/Extension.hs	2012-02-04 12:30:24.000000000 +0100
+@@ -18,7 +18,7 @@
+ 
+ x = UP [0,1] :: UPoly Integer
+ 
+-instance (Show a, Num a) => Show (UPoly a) where
++instance (Show a, Eq a, Num a) => Show (UPoly a) where
+     -- show (UP []) = "0"
+     show (UP as) = showUP "x" as
+ 
+@@ -39,7 +39,7 @@
+                         | i == 1 = v -- "x"
+                         | i > 1  = v ++ "^" ++ show i -- "x^" ++ show i
+ 
+-instance Num a => Num (UPoly a) where
++instance (Eq a, Num a) => Num (UPoly a) where
+     UP as + UP bs = toUPoly $ as <+> bs
+     negate (UP as) = UP $ map negate as
+     UP as * UP bs = toUPoly $ as <*> bs
+@@ -78,7 +78,7 @@
+ monomial a i = UP $ replicate i 0 ++ [a]
+ 
+ -- quotRem for UPolys over a field
+-quotRemUP :: (Num k, Fractional k) => UPoly k -> UPoly k -> (UPoly k, UPoly k)
++quotRemUP :: (Eq k, Num k, Fractional k) => UPoly k -> UPoly k -> (UPoly k, UPoly k)
+ quotRemUP f g = qr 0 f where
+     qr q r = if deg r < deg_g
+              then (q,r)
+@@ -105,12 +105,12 @@
+ 
+ data ExtensionField k poly = Ext (UPoly k) deriving (Eq,Ord)
+ 
+-instance Num k => Show (ExtensionField k poly) where
++instance (Show k, Eq k, Num k) => Show (ExtensionField k poly) where
+     -- show (Ext f) = show f
+     -- show (Ext (UP [])) = "0"
+     show (Ext (UP as)) = showUP "a" as
+ 
+-instance (Num k, Fractional k, PolynomialAsType k poly) => Num (ExtensionField k poly) where
++instance (Eq k, Num k, Fractional k, PolynomialAsType k poly) => Num (ExtensionField k poly) where
+     Ext x + Ext y = Ext $ (x+y) -- `modUP` pvalue (undefined :: (k,poly))
+     Ext x * Ext y = Ext $ (x*y) `modUP` pvalue (undefined :: (k,poly))
+     negate (Ext x) = Ext $ negate x
+@@ -118,7 +118,7 @@
+     abs _ = error "Prelude.Num.abs: inappropriate abstraction"
+     signum _ = error "Prelude.Num.signum: inappropriate abstraction"
+ 
+-instance (Num k, Fractional k, PolynomialAsType k poly) => Fractional (ExtensionField k poly) where
++instance (Eq k, Num k, Fractional k, PolynomialAsType k poly) => Fractional (ExtensionField k poly) where
+     recip 0 = error "ExtensionField.recip 0"
+     recip (Ext f) = let g = pvalue (undefined :: (k,poly))
+                         (u,v,d@(UP [c])) = extendedEuclidUP f g
+@@ -130,7 +130,7 @@
+ c /> f@(UP as) | c == 1 = f
+                | c /= 0 = UP (map (c' *) as) where c' = recip c
+ 
+-instance (FiniteField k, PolynomialAsType k poly) => FiniteField (ExtensionField k poly) where
++instance (Eq k, FiniteField k, PolynomialAsType k poly) => FiniteField (ExtensionField k poly) where
+     eltsFq _ = map Ext (polys (d-1) fp) where
+         fp = eltsFq (undefined :: k)
+         d = deg $ pvalue (undefined :: (k,poly))
+@@ -243,4 +243,4 @@
+ -- conjugate of a + b sqrt d is a - b sqrt d
+ conjugate :: ExtensionField Q (Sqrt d) -> ExtensionField Q (Sqrt d)
+ conjugate (Ext (UP [a,b])) = Ext (UP [a,-b])
+-conjugate x = x -- the zero or constant cases
+\ No newline at end of file
++conjugate x = x -- the zero or constant cases
+Index: haskell-maths-0.4.1/Math/Algebra/NonCommutative/NCPoly.hs
+===================================================================
+--- haskell-maths-0.4.1.orig/Math/Algebra/NonCommutative/NCPoly.hs	2011-11-10 22:38:12.000000000 +0100
++++ haskell-maths-0.4.1/Math/Algebra/NonCommutative/NCPoly.hs	2012-02-04 12:32:06.000000000 +0100
+@@ -58,7 +58,7 @@
+                                  then "+(" ++ c:cs ++ ")"
+                                  else if c == '-' then c:cs else '+':c:cs
+ 
+-instance (Ord v, Show v, Num r) => Num (NPoly r v) where
++instance (Ord v, Show v, Eq r, Num r) => Num (NPoly r v) where
+     NP ts + NP us = NP (mergeTerms ts us)
+     negate (NP ts) = NP $ map (\(m,c) -> (m,-c)) ts
+     NP ts * NP us = NP $ collect $ L.sortBy cmpTerm $ [(g*h,c*d) | (g,c) <- ts, (h,d) <- us]
+@@ -85,7 +85,7 @@
+ 
+ -- Fractional instance so that we can enter fractional coefficients
+ -- Only lets us divide by field elements (with unit monomial), not any other polynomials
+-instance (Ord v, Show v, Fractional r) => Fractional (NPoly r v) where
++instance (Ord v, Show v, Eq r, Fractional r) => Fractional (NPoly r v) where
+     recip (NP [(1,c)]) = NP [(1, recip c)]
+     recip _ = error "NPoly.recip: only supported for (non-zero) constants"
+ 
+@@ -210,4 +210,4 @@
+ class Invertible a where
+     inv :: a -> a
+ 
+-x ^- k = inv x ^ k
+\ No newline at end of file
++x ^- k = inv x ^ k
+Index: haskell-maths-0.4.1/Math[...incomplete...]



More information about the Pkg-haskell-commits mailing list