packages feed

algebra 4.1 → 4.2

raw patch · 22 files changed

+85/−92 lines, 22 filesdep ~natsPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: nats

API changes (from Hackage documentation)

- Numeric.Algebra: class Integral n => Whole n
- Numeric.Algebra: toNatural :: Whole n => n -> Natural
- Numeric.Algebra.Complex: instance Typeable1 Complex
- Numeric.Algebra.Dual: instance Typeable1 Dual
- Numeric.Algebra.Hyperbolic: instance Typeable1 Hyper'
- Numeric.Algebra.Incidence: instance Typeable1 Interval
- Numeric.Algebra.Quaternion: instance Typeable1 Quaternion
- Numeric.Coalgebra.Categorical: instance Typeable1 Morphism
- Numeric.Coalgebra.Dual: instance Typeable1 Dual'
- Numeric.Coalgebra.Hyperbolic: instance Typeable1 Hyper
- Numeric.Coalgebra.Incidence: instance Typeable1 Interval'
- Numeric.Coalgebra.Quaternion: instance Typeable1 Quaternion'
- Numeric.Coalgebra.Trigonometric: instance Typeable1 Trig
- Numeric.Rig.Class: fromNaturalNum :: Num r => Natural -> r
- Numeric.Rig.Class: fromWhole :: (Whole n, Rig r) => n -> r
+ Numeric.Algebra.Complex: instance Typeable Complex
+ Numeric.Algebra.Dual: instance Typeable Dual
+ Numeric.Algebra.Hyperbolic: instance Typeable Hyper'
+ Numeric.Algebra.Incidence: instance Typeable Interval
+ Numeric.Algebra.Quaternion: instance Typeable Quaternion
+ Numeric.Coalgebra.Categorical: instance Typeable Morphism
+ Numeric.Coalgebra.Dual: instance Typeable Dual'
+ Numeric.Coalgebra.Hyperbolic: instance Typeable Hyper
+ Numeric.Coalgebra.Incidence: instance Typeable Interval'
+ Numeric.Coalgebra.Quaternion: instance Typeable Quaternion'
+ Numeric.Coalgebra.Trigonometric: instance Typeable Trig
- Numeric.Additive.Class: class Additive r where sinnum1p y0 x0 = f x0 (1 + y0) where f x y | even y = f (x + x) (y `quot` 2) | y == 1 = x | otherwise = g (x + x) (unsafePred y `quot` 2) x g x y z | even y = g (x + x) (y `quot` 2) z | y == 1 = x + z | otherwise = g (x + x) (unsafePred y `quot` 2) (x + z) sumWith1 f = maybe (error "Numeric.Additive.Semigroup.sumWith1: empty structure") id . foldl' mf Nothing where mf Nothing y = Just $! f y mf (Just x) y = Just $! x + f y
+ Numeric.Additive.Class: class Additive r where sinnum1p y0 x0 = f x0 (1 + y0) where f x y | even y = f (x + x) (y `quot` 2) | y == 1 = x | otherwise = g (x + x) (pred y `quot` 2) x g x y z | even y = g (x + x) (y `quot` 2) z | y == 1 = x + z | otherwise = g (x + x) (pred y `quot` 2) (x + z) sumWith1 f = maybe (error "Numeric.Additive.Semigroup.sumWith1: empty structure") id . foldl' mf Nothing where mf Nothing y = Just $! f y mf (Just x) y = Just $! x + f y
- Numeric.Additive.Class: sinnum1p :: (Additive r, Whole n) => n -> r -> r
+ Numeric.Additive.Class: sinnum1p :: Additive r => Natural -> r -> r
- Numeric.Algebra: charWord :: (Whole s, Bounded s) => proxy s -> Natural
+ Numeric.Algebra: charWord :: (Integral s, Bounded s) => proxy s -> Natural
- Numeric.Algebra: class Additive r where sinnum1p y0 x0 = f x0 (1 + y0) where f x y | even y = f (x + x) (y `quot` 2) | y == 1 = x | otherwise = g (x + x) (unsafePred y `quot` 2) x g x y z | even y = g (x + x) (y `quot` 2) z | y == 1 = x + z | otherwise = g (x + x) (unsafePred y `quot` 2) (x + z) sumWith1 f = maybe (error "Numeric.Additive.Semigroup.sumWith1: empty structure") id . foldl' mf Nothing where mf Nothing y = Just $! f y mf (Just x) y = Just $! x + f y
+ Numeric.Algebra: class Additive r where sinnum1p y0 x0 = f x0 (1 + y0) where f x y | even y = f (x + x) (y `quot` 2) | y == 1 = x | otherwise = g (x + x) (pred y `quot` 2) x g x y z | even y = g (x + x) (y `quot` 2) z | y == 1 = x + z | otherwise = g (x + x) (pred y `quot` 2) (x + z) sumWith1 f = maybe (error "Numeric.Additive.Semigroup.sumWith1: empty structure") id . foldl' mf Nothing where mf Nothing y = Just $! f y mf (Just x) y = Just $! x + f y
- Numeric.Algebra: class (LeftModule Natural m, RightModule Natural m) => Monoidal m where sinnum 0 _ = zero sinnum n x0 = f x0 n where f x y | even y = f (x + x) (y `quot` 2) | y == 1 = x | otherwise = g (x + x) (unsafePred y `quot` 2) x g x y z | even y = g (x + x) (y `quot` 2) z | y == 1 = x + z | otherwise = g (x + x) (unsafePred y `quot` 2) (x + z) sumWith f = foldl' (\ b a -> b + f a) zero
+ Numeric.Algebra: class (LeftModule Natural m, RightModule Natural m) => Monoidal m where sinnum 0 _ = zero sinnum n x0 = f x0 n where f x y | even y = f (x + x) (y `quot` 2) | y == 1 = x | otherwise = g (x + x) (pred y `quot` 2) x g x y z | even y = g (x + x) (y `quot` 2) z | y == 1 = x + z | otherwise = g (x + x) (pred y `quot` 2) (x + z) sumWith f = foldl' (\ b a -> b + f a) zero
- Numeric.Algebra: pow :: (Unital r, Whole n) => r -> n -> r
+ Numeric.Algebra: pow :: Unital r => r -> Natural -> r
- Numeric.Algebra: pow1p :: (Multiplicative r, Whole n) => r -> n -> r
+ Numeric.Algebra: pow1p :: Multiplicative r => r -> Natural -> r
- Numeric.Algebra: pow1pBand :: Whole n => r -> n -> r
+ Numeric.Algebra: pow1pBand :: r -> Natural -> r
- Numeric.Algebra: powBand :: (Unital r, Whole n) => r -> n -> r
+ Numeric.Algebra: powBand :: Unital r => r -> Natural -> r
- Numeric.Algebra: sinnum :: (Monoidal m, Whole n) => n -> m -> m
+ Numeric.Algebra: sinnum :: Monoidal m => Natural -> m -> m
- Numeric.Algebra: sinnum1p :: (Additive r, Whole n) => n -> r -> r
+ Numeric.Algebra: sinnum1p :: Additive r => Natural -> r -> r
- Numeric.Algebra: sinnum1pRep :: (Whole n, Functor m, Additive r) => n -> m r -> m r
+ Numeric.Algebra: sinnum1pRep :: (Functor m, Additive r) => Natural -> m r -> m r
- Numeric.Algebra: sinnumRep :: (Whole n, Functor m, Monoidal r) => n -> m r -> m r
+ Numeric.Algebra: sinnumRep :: (Functor m, Monoidal r) => Natural -> m r -> m r
- Numeric.Algebra.Class: class (LeftModule Natural m, RightModule Natural m) => Monoidal m where sinnum 0 _ = zero sinnum n x0 = f x0 n where f x y | even y = f (x + x) (y `quot` 2) | y == 1 = x | otherwise = g (x + x) (unsafePred y `quot` 2) x g x y z | even y = g (x + x) (y `quot` 2) z | y == 1 = x + z | otherwise = g (x + x) (unsafePred y `quot` 2) (x + z) sumWith f = foldl' (\ b a -> b + f a) zero
+ Numeric.Algebra.Class: class (LeftModule Natural m, RightModule Natural m) => Monoidal m where sinnum 0 _ = zero sinnum n x0 = f x0 n where f x y | even y = f (x + x) (y `quot` 2) | y == 1 = x | otherwise = g (x + x) (pred y `quot` 2) x g x y z | even y = g (x + x) (y `quot` 2) z | y == 1 = x + z | otherwise = g (x + x) (pred y `quot` 2) (x + z) sumWith f = foldl' (\ b a -> b + f a) zero
- Numeric.Algebra.Class: pow1p :: (Multiplicative r, Whole n) => r -> n -> r
+ Numeric.Algebra.Class: pow1p :: Multiplicative r => r -> Natural -> r
- Numeric.Algebra.Class: sinnum :: (Monoidal m, Whole n) => n -> m -> m
+ Numeric.Algebra.Class: sinnum :: Monoidal m => Natural -> m -> m
- Numeric.Algebra.Idempotent: pow1pBand :: Whole n => r -> n -> r
+ Numeric.Algebra.Idempotent: pow1pBand :: r -> Natural -> r
- Numeric.Algebra.Idempotent: powBand :: (Unital r, Whole n) => r -> n -> r
+ Numeric.Algebra.Idempotent: powBand :: Unital r => r -> Natural -> r
- Numeric.Algebra.Unital: pow :: (Unital r, Whole n) => r -> n -> r
+ Numeric.Algebra.Unital: pow :: Unital r => r -> Natural -> r
- Numeric.Band.Class: pow1pBand :: Whole n => r -> n -> r
+ Numeric.Band.Class: pow1pBand :: r -> Natural -> r
- Numeric.Band.Class: powBand :: (Unital r, Whole n) => r -> n -> r
+ Numeric.Band.Class: powBand :: Unital r => r -> Natural -> r
- Numeric.Module.Representable: sinnum1pRep :: (Whole n, Functor m, Additive r) => n -> m r -> m r
+ Numeric.Module.Representable: sinnum1pRep :: (Functor m, Additive r) => Natural -> m r -> m r
- Numeric.Module.Representable: sinnumRep :: (Whole n, Functor m, Monoidal r) => n -> m r -> m r
+ Numeric.Module.Representable: sinnumRep :: (Functor m, Monoidal r) => Natural -> m r -> m r
- Numeric.Rig.Characteristic: charWord :: (Whole s, Bounded s) => proxy s -> Natural
+ Numeric.Rig.Characteristic: charWord :: (Integral s, Bounded s) => proxy s -> Natural

Files

CHANGELOG.markdown view
@@ -1,3 +1,7 @@+4.2+---+* Support for `nats` version 1 and `base` 4.8's version of `Numeric.Natural`. This required monomorphizing some stuff to `Natural`, but that is more accurate than the previous hack anyways.+ 4.1 --- * Added Euclidean domains and the field of fractions.
algebra.cabal view
@@ -1,6 +1,6 @@ name:          algebra category:      Math, Algebra-version:       4.1+version:       4.2 license:       BSD3 cabal-version: >= 1.6 license-file:  LICENSE@@ -49,7 +49,7 @@     containers              >= 0.3     && < 0.6,     distributive            >= 0.2.2   && < 1,     mtl                     >= 2.0.1   && < 2.3,-    nats                    >= 0.1     && < 1,+    nats                    >= 0.1     && < 2,     semigroups              >= 0.9     && < 1,     semigroupoids           >= 4       && < 5,     transformers            >= 0.2     && < 0.5,
src/Numeric/Additive/Class.hs view
@@ -17,8 +17,8 @@ import Data.Word import Data.Foldable hiding (concat) import Data.Semigroup.Foldable-import Numeric.Natural.Internal-import Prelude ((-),Bool(..),($),id,(>>=),fromIntegral,(*),otherwise,quot,maybe,error,even,Maybe(..),(==),(.),($!),Integer,(||),toInteger)+import Numeric.Natural+import Prelude ((-),Bool(..),($),id,(>>=),fromIntegral,(*),otherwise,quot,maybe,error,even,Maybe(..),(==),(.),($!),Integer,(||),pred) import qualified Prelude import Data.List.NonEmpty (NonEmpty(..), fromList) @@ -33,17 +33,17 @@   (+) :: r -> r -> r    -- | sinnum1p n r = sinnum (1 + n) r-  sinnum1p :: Whole n => n -> r -> r+  sinnum1p :: Natural -> r -> r   sinnum1p y0 x0 = f x0 (1 Prelude.+ y0)     where       f x y         | even y = f (x + x) (y `quot` 2)         | y == 1 = x-        | otherwise = g (x + x) (unsafePred y  `quot` 2) x+        | otherwise = g (x + x) (pred y  `quot` 2) x       g x y z         | even y = g (x + x) (y `quot` 2) z         | y == 1 = x + z-        | otherwise = g (x + x) (unsafePred y `quot` 2) (x + z)+        | otherwise = g (x + x) (pred y `quot` 2) (x + z)    sumWith1 :: Foldable1 f => (a -> r) -> f a -> r   sumWith1 f = maybe (error "Numeric.Additive.Semigroup.sumWith1: empty structure") id . foldl' mf Nothing@@ -64,11 +64,11 @@  instance Additive Natural where   (+) = (Prelude.+)-  sinnum1p n r = (1 Prelude.+ toNatural n) * r+  sinnum1p n r = (1 Prelude.+ fromIntegral n) * r  instance Additive Integer where    (+) = (Prelude.+)-  sinnum1p n r = (1 Prelude.+ toInteger n) * r+  sinnum1p n r = (1 Prelude.+ fromIntegral n) * r  instance Additive Int where   (+) = (Prelude.+)
src/Numeric/Algebra.hs view
@@ -105,7 +105,6 @@    -- * Natural numbers   , Natural-  , Whole(toNatural)    -- * Representable Additive   , addRep, sinnum1pRep@@ -155,7 +154,7 @@ import Numeric.Decidable.Zero import Numeric.Dioid.Class import Numeric.Module.Representable-import Numeric.Natural.Internal+import Numeric.Natural import Numeric.Order.Class import Numeric.Order.Additive import Numeric.Order.LocallyFinite
src/Numeric/Algebra/Class.hs view
@@ -33,7 +33,7 @@ import Data.Set (Set) import Data.Word import Numeric.Additive.Class-import Numeric.Natural.Internal+import Numeric.Natural import Prelude hiding ((*), (+), negate, subtract,(-), recip, (/), foldr, sum, product, replicate, concat) import qualified Data.IntMap as IntMap import qualified Data.IntSet as IntSet@@ -51,7 +51,7 @@  -- class Multiplicative r => PowerAssociative r where   -- pow1p x n = pow x (1 + n)-  pow1p :: Whole n => r -> n -> r+  pow1p :: r -> Natural -> r   pow1p x0 y0 = f x0 (y0 Prelude.+ 1) where     f x y        | even y = f (x * x) (y `quot` 2)@@ -300,7 +300,7 @@   (.*) = (*)  instance LeftModule Natural Integer where -  Natural n .* m = n * m+  n .* m = toInteger n * m  instance LeftModule Integer Integer where    (.*) = (*) @@ -397,7 +397,7 @@  instance RightModule Natural Natural where (*.) = (*) -instance RightModule Natural Integer where n *. Natural m = n * m+instance RightModule Natural Integer where n *. m = n * fromIntegral m  instance RightModule Integer Integer where (*.) = (*)  @@ -475,18 +475,18 @@ class (LeftModule Natural m, RightModule Natural m) => Monoidal m where   zero :: m -  sinnum :: Whole n => n -> m -> m+  sinnum :: Natural -> m -> m   sinnum 0 _  = zero   sinnum n x0 = f x0 n     where       f x y         | even y = f (x + x) (y `quot` 2)         | y == 1 = x-        | otherwise = g (x + x) (unsafePred y `quot` 2) x+        | otherwise = g (x + x) (pred y `quot` 2) x       g x y z         | even y = g (x + x) (y `quot` 2) z         | y == 1 = x + z-        | otherwise = g (x + x) (unsafePred y `quot` 2) (x + z)+        | otherwise = g (x + x) (pred y `quot` 2) (x + z)    sumWith :: Foldable f => (a -> m) -> f a -> m   sumWith f = foldl' (\b a -> b + f a) zero@@ -505,7 +505,7 @@  instance Monoidal Natural where   zero = 0-  sinnum n r = toNatural n * r+  sinnum n r = fromIntegral n * r  instance Monoidal Integer where    zero = 0
src/Numeric/Algebra/Idempotent.hs view
@@ -20,10 +20,10 @@ -- > a * a = a class Multiplicative r => Band r -pow1pBand :: Whole n => r -> n -> r+pow1pBand :: r -> Natural -> r pow1pBand r _ = r  -powBand :: (Unital r, Whole n) => r -> n -> r+powBand :: Unital r => r -> Natural -> r powBand _ 0 = one powBand r _ = r 
src/Numeric/Algebra/Involutive.hs view
@@ -15,14 +15,12 @@   , TriviallyInvolutiveBialgebra   ) where +import Data.Int+import Data.Word import Numeric.Algebra.Class import Numeric.Algebra.Commutative import Numeric.Algebra.Unital-import Data.Int-import Data.Word-import Numeric.Natural.Internal--+import Numeric.Natural  -- | An semigroup with involution -- 
src/Numeric/Algebra/Unital.hs view
@@ -13,7 +13,7 @@   ) where  import Numeric.Algebra.Class-import Numeric.Natural.Internal+import Numeric.Natural import Data.Sequence (Seq) import qualified Data.Sequence as Seq import Data.Foldable hiding (product)@@ -25,7 +25,7 @@  class Multiplicative r => Unital r where   one :: r-  pow :: Whole n => r -> n -> r+  pow :: r -> Natural -> r   pow _ 0 = one   pow x0 y0 = f x0 y0 where     f x y 
src/Numeric/Decidable/Associates.hs view
@@ -8,7 +8,7 @@ import Data.Int import Data.Word import Numeric.Algebra.Unital-import Numeric.Natural.Internal+import Numeric.Natural  isAssociateIntegral :: (Eq n, Num n) => n -> n -> Bool isAssociateIntegral = (==) `on` abs
src/Numeric/Decidable/Units.hs view
@@ -9,7 +9,7 @@ import Data.Word import Numeric.Algebra.Class import Numeric.Algebra.Unital-import Numeric.Natural.Internal+import Numeric.Natural import Control.Applicative import Prelude hiding ((*)) 
src/Numeric/Decidable/Zero.hs view
@@ -5,7 +5,7 @@ import Numeric.Algebra.Class import Data.Int import Data.Word-import Numeric.Natural.Internal+import Numeric.Natural  class Monoidal r => DecidableZero r where   isZero :: r -> Bool
src/Numeric/Module/Representable.hs view
@@ -24,7 +24,7 @@ import Numeric.Additive.Group import Numeric.Algebra.Class import Numeric.Algebra.Unital-import Numeric.Natural.Internal+import Numeric.Natural import Numeric.Rig.Class import Numeric.Ring.Class import Control.Category@@ -35,7 +35,7 @@ addRep = liftA2 (+)  -- | `Additive.sinnum1p` default definition-sinnum1pRep :: (Whole n, Functor m, Additive r) => n -> m r -> m r+sinnum1pRep :: (Functor m, Additive r) => Natural -> m r -> m r sinnum1pRep = fmap . sinnum1p  -- | `Monoidal.zero` default definition@@ -43,7 +43,7 @@ zeroRep = pure zero  -- | `Monoidal.sinnum` default definition-sinnumRep :: (Whole n, Functor m, Monoidal r) => n -> m r -> m r+sinnumRep :: (Functor m, Monoidal r) => Natural -> m r -> m r sinnumRep = fmap . sinnum  -- | `Group.negate` default definition
src/Numeric/Order/Additive.hs view
@@ -2,7 +2,7 @@   ( AdditiveOrder   ) where -import Numeric.Natural.Internal+import Numeric.Natural import Numeric.Additive.Class import Numeric.Order.Class 
src/Numeric/Order/Class.hs view
@@ -6,7 +6,7 @@ import Data.Int import Data.Word import Data.Set-import Numeric.Natural.Internal+import Numeric.Natural  -- a partial order (a, <=) class Order a where
src/Numeric/Order/LocallyFinite.hs view
@@ -8,7 +8,7 @@ import Numeric.Algebra.Class import Numeric.Algebra.Unital import Numeric.Order.Class-import Numeric.Natural.Internal+import Numeric.Natural import Numeric.Rig.Class import Numeric.Ring.Class import Data.Int@@ -18,6 +18,7 @@ import qualified Data.Set as Set import qualified Data.Ix as Ix import Prelude hiding ((*),(+),fromIntegral,(<),negate,(-))+import qualified Prelude  class Order a => LocallyFiniteOrder a where   range :: a -> a -> [a]@@ -33,17 +34,17 @@ instance LocallyFiniteOrder Natural where   range = curry Ix.range   rangeSize a b -    | a <= b = Natural (runNatural b - runNatural a + 1)+    | a <= b = Prelude.fromInteger (toInteger b - toInteger a + 1)     | otherwise = 0   moebiusInversion x y = case compare x y of      EQ -> one-     LT | unsafePred y == x -> negate one +     LT | pred y == x -> negate one       _ -> zero  instance LocallyFiniteOrder Integer where   range = curry Ix.range   rangeSize a b -    | a <= b = Natural (b - a + 1)+    | a <= b = Prelude.fromInteger (b - a + 1)     | otherwise = 0   moebiusInversion x y = case compare x y of      EQ -> one@@ -87,7 +88,7 @@ instance LocallyFiniteOrder Int where   range = curry Ix.range   rangeSize a b-    | a <= b = Natural $ fromIntegral $ b - a + 1+    | a <= b = Prelude.fromIntegral $ b - a + 1     | otherwise = 0   moebiusInversion x y = case compare x y of      EQ -> one@@ -97,7 +98,7 @@ instance LocallyFiniteOrder Int8 where   range = curry Ix.range   rangeSize a b-    | a <= b = Natural $ fromIntegral $ b - a + 1+    | a <= b = Prelude.fromIntegral $ b - a + 1     | otherwise = 0   moebiusInversion x y = case compare x y of      EQ -> one@@ -107,7 +108,7 @@ instance LocallyFiniteOrder Int16 where   range = curry Ix.range   rangeSize a b-    | a <= b = Natural $ fromIntegral $ b - a + 1+    | a <= b = Prelude.fromIntegral $ b - a + 1     | otherwise = 0   moebiusInversion x y = case compare x y of      EQ -> one@@ -117,7 +118,7 @@ instance LocallyFiniteOrder Int32 where   range = curry Ix.range   rangeSize a b-    | a <= b = Natural $ fromIntegral $ b - a + 1+    | a <= b = Prelude.fromIntegral $ b - a + 1     | otherwise = 0   moebiusInversion x y = case compare x y of      EQ -> one@@ -127,7 +128,7 @@ instance LocallyFiniteOrder Int64 where   range = curry Ix.range   rangeSize a b-    | a <= b = Natural $ fromIntegral $ b - a + 1+    | a <= b = Prelude.fromIntegral $ b - a + 1     | otherwise = 0   moebiusInversion x y = case compare x y of      EQ -> one@@ -137,7 +138,7 @@ instance LocallyFiniteOrder Word where   range = curry Ix.range   rangeSize a b-    | a <= b = Natural $ fromIntegral $ b - a + 1+    | a <= b = Prelude.fromIntegral $ b - a + 1     | otherwise = 0   moebiusInversion x y = case compare x y of      EQ -> one@@ -147,7 +148,7 @@ instance LocallyFiniteOrder Word8 where   range = curry Ix.range   rangeSize a b-    | a <= b = Natural $ fromIntegral $ b - a + 1+    | a <= b = Prelude.fromIntegral $ b - a + 1     | otherwise = 0   moebiusInversion x y = case compare x y of      EQ -> one@@ -157,7 +158,7 @@ instance LocallyFiniteOrder Word16 where   range = curry Ix.range   rangeSize a b-    | a <= b = Natural $ fromIntegral $ b - a + 1+    | a <= b = Prelude.fromIntegral $ b - a + 1     | otherwise = 0   moebiusInversion x y = case compare x y of      EQ -> one@@ -167,7 +168,7 @@ instance LocallyFiniteOrder Word32 where   range = curry Ix.range   rangeSize a b-    | a <= b = Natural $ fromIntegral $ b - a + 1+    | a <= b = Prelude.fromIntegral $ b - a + 1     | otherwise = 0   moebiusInversion x y = case compare x y of      EQ -> one@@ -177,7 +178,7 @@ instance LocallyFiniteOrder Word64 where   range = curry Ix.range   rangeSize a b-    | a <= b = Natural $ fromIntegral $ b - a + 1+    | a <= b = Prelude.fromIntegral $ b - a + 1     | otherwise = 0   moebiusInversion x y = case compare x y of      EQ -> one
src/Numeric/Partial/Monoid.hs view
@@ -5,7 +5,7 @@ import Numeric.Partial.Semigroup import Data.Int import Data.Word-import Numeric.Natural.Internal+import Numeric.Natural  class PartialSemigroup a => PartialMonoid a where   pzero :: a
src/Numeric/Partial/Semigroup.hs view
@@ -5,7 +5,7 @@ import Control.Applicative import Data.Word import Data.Int-import Numeric.Natural.Internal+import Numeric.Natural  class PartialSemigroup a where   padd :: a -> a -> Maybe a
src/Numeric/Quadrance/Class.hs view
@@ -9,7 +9,7 @@ import Numeric.Algebra.Class import Numeric.Algebra.Unital import Numeric.Rig.Class-import Numeric.Natural.Internal+import Numeric.Natural import Prelude hiding ((+),(*))  -- a module with a computable squared norm@@ -42,40 +42,40 @@ sq r = r * r  instance Rig r => Quadrance r Int where-  quadrance = fromNatural . Natural . sq . toInteger+  quadrance = fromNatural . fromIntegral . sq . toInteger  instance Rig r => Quadrance r Word where-  quadrance = fromNatural . Natural . sq . toInteger+  quadrance = fromNatural . fromIntegral . sq . toInteger  instance Rig r => Quadrance r Natural where-  quadrance = fromNatural . Natural . sq . toInteger+  quadrance = fromNatural . fromIntegral . sq . toInteger  instance Rig r => Quadrance r Integer where -  quadrance = fromNatural . Natural . fromInteger . sq+  quadrance = fromNatural . fromInteger . sq  instance Rig r => Quadrance r Int8 where -  quadrance = fromNatural . Natural . sq . toInteger+  quadrance = fromNatural . fromIntegral . sq . toInteger  instance Rig r => Quadrance r Int16 where -  quadrance = fromNatural . Natural . sq . toInteger+  quadrance = fromNatural . fromIntegral . sq . toInteger  instance Rig r => Quadrance r Int32 where-  quadrance = fromNatural . Natural . sq . toInteger+  quadrance = fromNatural . fromIntegral . sq . toInteger  instance Rig r => Quadrance r Int64 where-  quadrance = fromNatural . Natural . sq . toInteger+  quadrance = fromNatural . fromIntegral . sq . toInteger  instance Rig r => Quadrance r Word8 where -  quadrance = fromNatural . Natural . sq . toInteger+  quadrance = fromNatural . fromIntegral . sq . toInteger  instance Rig r => Quadrance r Word16 where -  quadrance = fromNatural . Natural . sq . toInteger+  quadrance = fromNatural . fromIntegral . sq . toInteger  instance Rig r => Quadrance r Word32 where-  quadrance = fromNatural . Natural . sq . toInteger+  quadrance = fromNatural . fromIntegral . sq . toInteger  instance Rig r => Quadrance r Word64 where-  quadrance = fromNatural . Natural . sq . toInteger+  quadrance = fromNatural . fromIntegral . sq . toInteger  {- instance InvolutiveSemiring r => Quadrance r (Complex r) where
src/Numeric/Rig/Characteristic.hs view
@@ -7,7 +7,7 @@ import Data.Int import Data.Word import Numeric.Rig.Class-import Numeric.Natural.Internal+import Numeric.Natural import Prelude hiding ((^))  data Proxy p = Proxy@@ -21,8 +21,8 @@ asProxyTypeOf :: a -> p a -> a asProxyTypeOf = const -charWord :: (Whole s, Bounded s) => proxy s -> Natural-charWord p = toNatural (maxBound `asProxyTypeOf` p) + 1+charWord :: (Integral s, Bounded s) => proxy s -> Natural+charWord p = fromIntegral (maxBound `asProxyTypeOf` p) + 1  -- | NB: we're using the boolean semiring, not the boolean ring instance Characteristic Bool where char _ = 0
src/Numeric/Rig/Class.hs view
@@ -1,41 +1,32 @@ module Numeric.Rig.Class   ( Rig(..)-  , fromNaturalNum-  , fromWhole   ) where  import Numeric.Algebra.Class import Numeric.Algebra.Unital import Data.Int import Data.Word-import Prelude (Integer, Bool, Num(fromInteger),(/=),id,(.))-import Numeric.Natural.Internal--fromNaturalNum :: Num r => Natural -> r-fromNaturalNum (Natural n) = fromInteger n+import Prelude (Integer,Bool,(/=),id,fromIntegral)+import Numeric.Natural  -- | A Ring without (n)egation class (Semiring r, Unital r, Monoidal r) => Rig r where   fromNatural :: Natural -> r   fromNatural n = sinnum n one -fromWhole :: (Whole n, Rig r) => n -> r-fromWhole = fromNatural . toNatural--- TODO: optimize--instance Rig Integer where fromNatural = fromNaturalNum+instance Rig Integer where fromNatural = fromIntegral instance Rig Natural where fromNatural = id instance Rig Bool where fromNatural = (/=) 0-instance Rig Int where fromNatural = fromNaturalNum-instance Rig Int8 where fromNatural = fromNaturalNum-instance Rig Int16 where fromNatural = fromNaturalNum-instance Rig Int32 where fromNatural = fromNaturalNum-instance Rig Int64 where fromNatural = fromNaturalNum-instance Rig Word where fromNatural = fromNaturalNum-instance Rig Word8 where fromNatural = fromNaturalNum-instance Rig Word16 where fromNatural = fromNaturalNum-instance Rig Word32 where fromNatural = fromNaturalNum-instance Rig Word64 where fromNatural = fromNaturalNum+instance Rig Int where fromNatural = fromIntegral+instance Rig Int8 where fromNatural = fromIntegral+instance Rig Int16 where fromNatural = fromIntegral+instance Rig Int32 where fromNatural = fromIntegral+instance Rig Int64 where fromNatural = fromIntegral+instance Rig Word where fromNatural = fromIntegral+instance Rig Word8 where fromNatural = fromIntegral+instance Rig Word16 where fromNatural = fromIntegral+instance Rig Word32 where fromNatural = fromIntegral+instance Rig Word64 where fromNatural = fromIntegral instance Rig () where fromNatural _ = () instance (Rig a, Rig b) => Rig (a, b) where   fromNatural n = (fromNatural n, fromNatural n)
src/Numeric/Rig/Ordered.hs view
@@ -4,7 +4,7 @@  import Numeric.Rig.Class import Numeric.Order.Additive-import Numeric.Natural.Internal+import Numeric.Natural  -- x <= y ==> x + z <= y + z -- 0 <= x && y <= z implies xy <= xz
src/Numeric/Semiring/Integral.hs view
@@ -3,7 +3,7 @@   ) where  import Numeric.Algebra.Class-import Numeric.Natural.Internal+import Numeric.Natural  -- | An integral semiring has no zero divisors --