semirings 0.1.2 → 0.1.3.0
raw patch · 3 files changed
+29/−39 lines, 3 filesdep −constrictorPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: constrictor
API changes (from Hackage documentation)
- Data.Semiring: instance (GHC.Base.Applicative f, Data.Semiring.Semiring a) => Data.Semiring.Semiring (Constrictor.Ap f a)
Files
- CHANGELOG.md +5/−0
- Data/Semiring.hs +17/−24
- semirings.cabal +7/−15
CHANGELOG.md view
@@ -1,3 +1,8 @@+0.1.3.0: [2018.05.23]+---------------------+* remove dependency on `constrictor`.+* some doc fixes.+ 0.1.2: [2018.05.04] ------------------- * `semirings` now builds back to
Data/Semiring.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE BangPatterns #-} {-# LANGUAGE CPP #-} {-# LANGUAGE DefaultSignatures #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}@@ -29,9 +30,6 @@ , minus ) where -#if defined(VERSION_constrictor)-import Constrictor (Ap(..))-#endif import Control.Applicative (Alternative(..), Applicative(..), Const(..), liftA2) import Data.Bool (Bool(..), (||), (&&), otherwise, not) import Data.Complex (Complex(..))@@ -177,8 +175,8 @@ -- can think of a semiring as two monoids of the same -- underlying type: A commutative monoid and an -- associative monoid. For any type R with a 'Prelude.Num'--- instance, the commutative monoid is (R, '(Prelude.+)', 0)--- and the associative monoid is (R, '(Prelude.*)', 1).+-- instance, the commutative monoid is (R, 'GHC.Num.+', 0)+-- and the associative monoid is (R, 'GHC.Num.*', 1). -- -- Instances should satisfy the following laws: --@@ -204,25 +202,30 @@ -- -- [/left- and right-distributivity of '*' over '+'/] ----- @x '*' (y '+' z) = (x '*' y) '+' (x '*' z)@--- @(x '+' y) '*' z = (x '*' z) '+' (y '*' z)@+-- @+-- x '*' (y '+' z) = (x '*' y) '+' (x '*' z)+-- (x '+' y) '*' z = (x '*' z) '+' (y '*' z)+-- @ -- -- [/annihilation/] -- -- @'zero' '*' x = x '*' 'zero' = 'zero'@+-- class Semiring a where+#if __GLASGOW_HASKELL__ >= 708 {-# MINIMAL plus, zero, times, one #-}+#endif plus :: a -> a -> a -- ^ Commutative Operation zero :: a -- ^ Commutative Unit times :: a -> a -> a -- ^ Associative Operation one :: a -- ^ Associative Unit -- useful for defining semirings over ground types- default zero :: Num.Num a => a -- ^ 0- default one :: Num.Num a => a -- ^ 1- default plus :: Num.Num a => a -> a -> a -- ^ '(Prelude.+)'- default times :: Num.Num a => a -> a -> a -- ^ '(Prelude.*)'+ default zero :: Num.Num a => a+ default one :: Num.Num a => a+ default plus :: Num.Num a => a -> a -> a+ default times :: Num.Num a => a -> a -> a zero = 0 one = 1 plus = (Num.+)@@ -233,14 +236,16 @@ -- @'negate' a '+' a = 'zero'@ class Semiring a => Ring a where+#if __GLASGOW_HASKELL__ >= 708 {-# MINIMAL negate #-}+#endif negate :: a -> a default negate :: Num.Num a => a -> a negate = Num.negate -- | Substract two 'Ring' values. For any type 'R' with--- a 'Prelude.Num' instance, this is the same as '(Prelude.-)'.+-- a 'Prelude.Num' instance, this is the same as Prelude's 'GHC.Num.-'. -- -- @x `minus` y = x '+' 'negate' y@ minus :: Ring a => a -> a -> a@@ -498,18 +503,6 @@ deriving instance Ring a => Ring (Max a) deriving instance Ring a => Ring (Min a) instance HasResolution a => Ring (Fixed a)--{--------------------------------------------------------------------- Instances (constrictor)---------------------------------------------------------------------}--#if defined(VERSION_constrictor)-instance (Applicative f, Semiring a) => Semiring (Ap f a) where- zero = Ap (pure zero)- one = Ap (pure one)- plus = liftA2 plus- times = liftA2 times-#endif {-------------------------------------------------------------------- Instances (containers)
semirings.cabal view
@@ -1,6 +1,6 @@ name: semirings category: Algebra, Data, Data Structures, Math, Maths, Mathematics-version: 0.1.2+version: 0.1.3.0 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -49,14 +49,6 @@ default: True manual: True -flag constrictor- description:- You can disable the use of the `constrictor` package using `-f-constrictor`.- .- Disabling this may be useful for accelerating builds in sandboxes for expert users.- default: True- manual: True- flag containers description: You can disable the use of the `containers` package using `-f-containers`.@@ -88,11 +80,14 @@ build-depends: base >= 4.5 && < 5 , integer-gmp- , semigroups- , transformers if impl(ghc < 7.10)- build-depends: nats >= 0.1 && < 2+ build-depends:+ nats >= 0.1 && < 2+ , transformers++ if impl(ghc < 8.0)+ build-depends: semigroups if impl(ghc >= 7.2) exposed-modules:@@ -101,9 +96,6 @@ if impl(ghc >= 7.6.1) exposed-modules: Data.Semiring.Generic- - if flag(constrictor)- build-depends: constrictor >= 0.1.1.1 && < 0.2.0.0 if flag(containers) build-depends: containers >= 0.3 && < 0.6