packages feed

numhask 0.10.1.0 → 0.10.1.1

raw patch · 11 files changed

+46/−56 lines, 11 files

Files

numhask.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               numhask-version:            0.10.1.0+version:            0.10.1.1 synopsis:           A numeric class hierarchy. description:   This package provides alternative numeric classes over Prelude.@@ -25,7 +25,9 @@ license:            BSD-3-Clause license-file:       LICENSE build-type:         Simple-tested-with:        GHC ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.2.2+tested-with:+  GHC ==8.6.5 || ==8.8.4 || ==8.10.7 || ==9.2.5 || ==9.4.4+ extra-doc-files:    other/*.svg extra-source-files: ChangeLog.md @@ -36,14 +38,12 @@  library   hs-source-dirs:           src-     ghc-options:     -Wall -Wcompat -Wincomplete-record-updates-    -Wincomplete-uni-patterns -Wredundant-constraints -    -  if impl(ghc >= 8.8)-    ghc-options:       -      -fwrite-ide-info -hiedir=.hie+    -Wincomplete-uni-patterns -Wredundant-constraints++  if impl(ghc >=8.8)+    ghc-options: -fwrite-ide-info -hiedir=.hie    x-docspec-extra-packages: QuickCheck   build-depends:            base >=4.7 && <5
src/NumHask.hs view
@@ -218,10 +218,10 @@ -- -- >>> :set -XNoRebindableSyntax -- >>> :t 1--- 1 :: Num p => p+-- 1 :: Num a => a -- -- >>> :t 1.0--- 1.0 :: Fractional p => p+-- 1.0 :: Fractional a => a -- -- With RebindableSyntax (which also switches NoImplicitPrelude on) literal numbers change to the numhask types, 'FromInteger' and 'FromRational': --@@ -275,7 +275,6 @@ -- -- The class heirarchy looks somewhat like this: -- ![classes](other/nh.svg)---  -- $mapping --
src/NumHask/Algebra/Additive.hs view
@@ -183,9 +183,9 @@ instance Subtractive Word64 where   negate = P.negate -instance Additive b => Additive (a -> b) where+instance (Additive b) => Additive (a -> b) where   f + f' = \a -> f a + f' a   zero _ = zero -instance Subtractive b => Subtractive (a -> b) where+instance (Subtractive b) => Subtractive (a -> b) where   negate f = negate P.. f
src/NumHask/Algebra/Field.hs view
@@ -69,7 +69,7 @@  instance Field P.Float -instance Field b => Field (a -> b)+instance (Field b) => Field (a -> b)  -- | A hyperbolic field class --@@ -109,7 +109,7 @@   log = P.log   (**) = (P.**) -instance ExpField b => ExpField (a -> b) where+instance (ExpField b) => ExpField (a -> b) where   exp f = exp . f   log f = log . f @@ -189,7 +189,7 @@ instance QuotientField P.Double P.Int where   properFraction = P.properFraction -instance QuotientField b c => QuotientField (a -> b) (a -> c) where+instance (QuotientField b c) => QuotientField (a -> b) (a -> c) where   properFraction f = (P.fst . frac, P.snd . frac)     where       frac a = properFraction @b @c (f a)@@ -276,7 +276,7 @@   acosh = P.acosh   atanh = P.atanh -instance TrigField b => TrigField (a -> b) where+instance (TrigField b) => TrigField (a -> b) where   pi _ = pi   sin f = sin . f   cos f = cos . f
src/NumHask/Algebra/Group.hs view
@@ -41,7 +41,7 @@   infix 3 ⊕   (⊕) :: a -> a -> a -instance Magma b => Magma (a -> b) where+instance (Magma b) => Magma (a -> b) where   f ⊕ g = \a -> f a ⊕ g a  -- | A Unital Magma is a magma with an@@ -51,12 +51,12 @@ -- > unit ⊕ a = a -- > a ⊕ unit = a class-  Magma a =>+  (Magma a) =>   Unital a   where   unit :: a -instance Unital b => Unital (a -> b) where+instance (Unital b) => Unital (a -> b) where   {-# INLINE unit #-}   unit _ = unit @@ -64,31 +64,31 @@ -- -- > (a ⊕ b) ⊕ c = a ⊕ (b ⊕ c) class-  Magma a =>+  (Magma a) =>   Associative a -instance Associative b => Associative (a -> b)+instance (Associative b) => Associative (a -> b)  -- | A Commutative Magma is a Magma where the binary operation is -- <https://en.wikipedia.org/wiki/Commutative_property commutative>. -- -- > a ⊕ b = b ⊕ a class-  Magma a =>+  (Magma a) =>   Commutative a -instance Commutative b => Commutative (a -> b)+instance (Commutative b) => Commutative (a -> b)  -- | An Invertible Magma -- -- > ∀ a,b ∈ T: inv a ⊕ (a ⊕ b) = b = (b ⊕ a) ⊕ inv a class-  Magma a =>+  (Magma a) =>   Invertible a   where   inv :: a -> a -instance Invertible b => Invertible (a -> b) where+instance (Invertible b) => Invertible (a -> b) where   {-# INLINE inv #-}   inv f = inv . f @@ -103,12 +103,12 @@ -- -- > a ⊕ absorb = absorb class-  Magma a =>+  (Magma a) =>   Absorbing a   where   absorb :: a -instance Absorbing b => Absorbing (a -> b) where+instance (Absorbing b) => Absorbing (a -> b) where   {-# INLINE absorb #-}   absorb _ = absorb @@ -117,10 +117,10 @@ -- -- > a ⊕ a = a class-  Magma a =>+  (Magma a) =>   Idempotent a -instance Idempotent b => Idempotent (a -> b)+instance (Idempotent b) => Idempotent (a -> b)  -- | An <https://en.wikipedia.org/wiki/Abelian_group Abelian Group> is an --   Associative, Unital, Invertible and Commutative Magma . In other words, it
src/NumHask/Algebra/Lattice.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE RebindableSyntax #-} {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wall #-}+{-# OPTIONS_GHC -Wno-redundant-constraints #-}  -- | [Lattices](https://en.wikipedia.org/wiki/Lattice_(order\)) module NumHask.Algebra.Lattice@@ -84,13 +85,13 @@ -- | A join-semilattice with an identity element 'bottom' for '\/'. -- -- > Identity: x \/ bottom == x-class JoinSemiLattice a => BoundedJoinSemiLattice a where+class (JoinSemiLattice a) => BoundedJoinSemiLattice a where   bottom :: a  -- | A meet-semilattice with an identity element 'top' for '/\'. -- -- > Identity: x /\ top == x-class MeetSemiLattice a => BoundedMeetSemiLattice a where+class (MeetSemiLattice a) => BoundedMeetSemiLattice a where   top :: a  -- | Lattices with both bounds
src/NumHask/Algebra/Multiplicative.hs view
@@ -147,9 +147,9 @@   (*) = (P.*)   one = 1 -instance Multiplicative b => Multiplicative (a -> b) where+instance (Multiplicative b) => Multiplicative (a -> b) where   f * f' = \a -> f a * f' a   one _ = one -instance Divisive b => Divisive (a -> b) where+instance (Divisive b) => Divisive (a -> b) where   recip f = recip P.. f
src/NumHask/Algebra/Ring.hs view
@@ -68,7 +68,7 @@  instance Distributive P.Bool -instance Distributive b => Distributive (a -> b)+instance (Distributive b) => Distributive (a -> b)  -- | A <https://en.wikipedia.org/wiki/Ring_(mathematics) Ring> is an abelian group under addition ('NumHask.Algebra.Unital', 'NumHask.Algebra.Associative', 'NumHask.Algebra.Commutative', 'NumHask.Algebra.Invertible') and monoidal under multiplication ('NumHask.Algebra.Unital', 'NumHask.Algebra.Associative'), and where multiplication distributes over addition. --@@ -105,7 +105,7 @@   plus :: a -> a   plus a = a * star a -instance StarSemiring b => StarSemiring (a -> b)+instance (StarSemiring b) => StarSemiring (a -> b)  -- | A <https://en.wikipedia.org/wiki/Kleene_algebra Kleene Algebra> is a Star Semiring with idempotent addition. --@@ -113,7 +113,7 @@ -- > x * a + x = a ==> x * star a + x = x class (StarSemiring a, Idempotent a) => KleeneAlgebra a -instance KleeneAlgebra b => KleeneAlgebra (a -> b)+instance (KleeneAlgebra b) => KleeneAlgebra (a -> b)  -- | Involutive Ring --@@ -155,7 +155,7 @@  instance InvolutiveRing Word64 -instance InvolutiveRing b => InvolutiveRing (a -> b)+instance (InvolutiveRing b) => InvolutiveRing (a -> b)  -- | Defining 'two' requires adding the multiplicative unital to itself. In other words, the concept of 'two' is a Ring one. --
src/NumHask/Data/Complex.hs view
@@ -135,7 +135,7 @@         | x P.== zero P.&& y P.> zero = pi / (one + one)         | x P.< one P.&& y P.> one = pi + atan (y / x)         | (x P.<= zero P.&& y P.< zero) || (x P.< zero) =-          negate (atan2' (negate y) x)+            negate (atan2' (negate y) x)         | y P.== zero = pi -- must be after the previous test on zero y         | x P.== zero P.&& y P.== zero = y -- must be after the other double zero tests         | P.otherwise = x + y -- x or y is a NaN, return a NaN (via +)
src/NumHask/Data/Integral.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE ConstraintKinds #-}-{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -114,7 +113,7 @@   divMod = P.divMod   quotRem = P.quotRem -instance Integral b => Integral (a -> b) where+instance (Integral b) => Integral (a -> b) where   div f f' a = f a `div` f' a   mod f f' a = f a `mod` f' a   divMod f f' = (\a -> fst (f a `divMod` f' a), \a -> snd (f a `divMod` f' a))@@ -129,8 +128,6 @@   {-# MINIMAL toIntegral #-}    toIntegral :: a -> b-  default toIntegral :: (a ~ b) => a -> b-  toIntegral = P.id  instance ToIntegral Integer Integer where   toIntegral = P.id@@ -241,8 +238,6 @@   {-# MINIMAL fromIntegral #-}    fromIntegral :: b -> a-  default fromIntegral :: (a ~ b) => b -> a-  fromIntegral = P.id  instance (FromIntegral a b) => FromIntegral (c -> a) b where   fromIntegral i _ = fromIntegral i
src/NumHask/Data/Rational.hs view
@@ -1,5 +1,4 @@ {-# LANGUAGE ConstraintKinds #-}-{-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-}@@ -50,8 +49,8 @@     | xa == zero P.&& xb == zero = P.True     | xa == zero P.|| xb == zero = P.False     | P.otherwise =-      let (xa' :% ya', xb' :% yb') = (reduce xa ya, reduce xb yb)-       in (xa' P.== xb') P.&& (ya' P.== yb')+        let (xa' :% ya', xb' :% yb') = (reduce xa ya, reduce xb yb)+         in (xa' P.== xb') P.&& (ya' P.== yb')  -- | Has a zero denominator isRNaN :: (P.Eq a, Additive a) => Ratio a -> P.Bool@@ -59,7 +58,7 @@   | x P.== zero P.&& y P.== zero = P.True   | P.otherwise = P.False -instance (P.Ord a, Integral a, Signed a, Multiplicative a, Subtractive a) => P.Ord (Ratio a) where+instance (P.Ord a, Integral a, Signed a, Subtractive a) => P.Ord (Ratio a) where   (x :% y) <= (x' :% y') = x * y' P.<= x' * y   (x :% y) < (x' :% y') = x * y' P.< x' * y @@ -75,7 +74,7 @@ instance (P.Ord a, Signed a, Integral a, Ring a) => Subtractive (Ratio a) where   negate (x :% y) = negate x :% y -instance (P.Ord a, Signed a, Integral a, Ring a, Multiplicative a) => Multiplicative (Ratio a) where+instance (P.Ord a, Signed a, Integral a, Ring a) => Multiplicative (Ratio a) where   (x :% y) * (x' :% y') = reduce (x * x') (y * y')    one = one :% one@@ -107,10 +106,10 @@   norm = abs   basis = sign -instance (P.Ord a, Integral a, Signed a, Multiplicative a, Subtractive a) => JoinSemiLattice (Ratio a) where+instance (P.Ord a, Integral a, Signed a, Subtractive a) => JoinSemiLattice (Ratio a) where   (\/) = P.min -instance (P.Ord a, Integral a, Signed a, Multiplicative a, Subtractive a) => MeetSemiLattice (Ratio a) where+instance (P.Ord a, Integral a, Signed a, Subtractive a) => MeetSemiLattice (Ratio a) where   (/\) = P.max  instance (P.Ord a, Signed a, Integral a, Ring a, MeetSemiLattice a) => Epsilon (Ratio a)@@ -124,8 +123,6 @@ -- 13176795 :% 4194304 class ToRatio a b where   toRatio :: a -> Ratio b-  default toRatio :: (Ratio c ~ a, FromIntegral b c, ToRatio (Ratio b) b) => a -> Ratio b-  toRatio (n :% d) = toRatio ((fromIntegral n :: b) :% fromIntegral d)  instance ToRatio Double Integer where   toRatio = fromBaseRational . P.toRational@@ -181,8 +178,6 @@ -- 2.5 class FromRatio a b where   fromRatio :: Ratio b -> a-  default fromRatio :: (Ratio b ~ a) => Ratio b -> a-  fromRatio = P.id  fromBaseRational :: P.Rational -> Ratio Integer fromBaseRational (n GHC.Real.:% d) = n :% d