!y      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ Safe=?@AXk `Safe=?@AXk kringsA  is a  plus a function,  , such that:  a << negate a == mempty negate a << a == mempty6Safe 478=?@AXk8 rings Monoid under . Analogous to , but uses the   constraint, rather than . rings Infinite closures of a semiring.  adds a Kleene   operator to a  $, with an infinite closure property:   x "a   x  x   "a x    x  If r is a dioid then   must be monotonic:@x <~ y ==>   x <~   y See also 7https://en.wikipedia.org/wiki/Semiring#Kleene_semiringsclosed semiring rings@Right pre-semirings and (non-unital and unital) right semirings.HA right pre-semiring (sometimes referred to as a bisemigroup) is a type R endowed with two associative binary (i.e. semigroup) operations: (<>) and (><), along with a right-distributivity property connecting them:  (a <> b) > c"a (a c)< (b >< c) ]A non-unital right semiring (sometimes referred to as a bimonoid) is a pre-semiring with a J element that is neutral with respect to both addition and multiplication.NA unital right semiring is a pre-semiring with two distinct neutral elements,  and  , such that  is right-neutral wrt addition, , is right-neutral wrt multiplication, and + is right-annihilative wrt multiplication.  Note that  needn't be distinct from T, moreover addition and multiplication needn't be commutative or left-distributive.CSee the properties module for a detailed specification of the laws.ringsHFold over a collection using the multiplicative operation of a semiring.  f "a  ((><) . f)  D(foldMap . product) id [[1, 2], [3, (4 :: Int)]] -- 1 >< 2 <> 3 >< 414D(product . foldMap) id [[1, 2], [3, (4 :: Int)]] -- 1 <> 2 >< 3 <> 421LFor semirings without a distinct multiplicative sunit this is equivalent to  const mempty:product Just [1..(5 :: Int)]Just 0.In this situation you most likely want to use .ringsRFold over a non-empty collection using the multiplicative operation of a semiring.TAs the collection is non-empty this does not require a distinct multiplicative unit:$product1 Just $ 1 :| [2..(5 :: Int)]Just 120ringsCross-multiply two collections.cross [1,2,3 :: Int] [1,2,3]36cross [1,2,3 :: Int] []0rings)Cross-multiply two non-empty collections.Mcross1 (Right 2 :| [Left "oops"]) (Right 2 :| [Right 3]) :: Either [Char] IntRight 4ringsA generalization of  to an arbitrary .  Adapted from  Jhttp://augustss.blogspot.com/2008/07/lost-and-found-if-i-write-108-in.html.3rings1'First a' forms a pre-semiring for any semigroup a.=foldMap1 First $ 1 :| [2..(5 :: Int)] >< 1 :| [2..(5 :: Int)]First {getFirst = 1}%product1 First $ 1 :| [2..(5 :: Int)]First {getFirst = 15}?foldMap1 First $ Nothing :| [Just (5 :: Int), Just 6, Nothing]First {getFirst = Nothing}?product1 First $ Nothing :| [Just (5 :: Int), Just 6, Nothing]First {getFirst = Just 11}    78Safe=?@AXk9@AB@ABSafe =?@AXk:ySafe =?@AXk:Safe =?@AXk;uSafe =?@AXk; Safe ,=?@AXkBHringsRight pre-dioids and dioids.RA right-dioid is a semiring with a right-canonical pre-order relation relative to : a <~ b iff  b "a a <> c for some c.In other words we have that: a  (a  b) "a   Consequently " is both reflexive and transitive: a  a "a  a  b && b  c ==> a  c "a  Finally  is an order relation: (a  b)  == (a  b)See   Safe=?@AXkB Safe =?@AXkyxrings! \forall a \in R: (z + a) \sim a BA (pre-)semiring with a right-neutral additive sunit must satisfy: neutral_addition  ~~ const True Or, equivalently:   r ~~ r This is a required property.rings! \forall a \in R: (o * a) \sim a HA (pre-)semiring with a right-neutral multiplicative sunit must satisfy: neutral_multiplication  ~~ const True Or, equivalently:   r ~~ r This is a required property.rings5 \forall a, b, c \in R: (a + b) + c \sim a + (b + c) R must right-associate addition.*This should be verified by the underlying 2 instance, but is included here for completeness.This is a required property.rings5 \forall a, b, c \in R: (a * b) * c \sim a * (b * c) R% must right-associate multiplication.This is a required property.rings; \forall a, b, c \in R: (a + b) * c \sim (a * c) + (b * c) R& must right-distribute multiplication.When R9 is a functor and the semiring structure is derived from  Alternative, this translates to:  (a <|> b)  c = (a  c) <|> (b  c) See  ?https://en.wikibooks.org/wiki/Haskell/Alternative_and_MonadPlus.This is a required property.rings* \forall a, b \in R: a * b \sim a * b + b If R is non-unital (i.e. sunit is not distinct from mempty>) then it will instead satisfy a right-absorbtion property. <This follows from right-neutrality and right-distributivity.Compare codistributive and  closed_stable.When R# is also left-distributive we get: + \forall a, b \in R: a * b = a + a * b + b  See also  and  ;https://blogs.ncl.ac.uk/andreymokhov/united-monoids/#whatif.rings! \forall a \in R: (z * a) \sim u A RF is unital then its addititive sunit must be right-annihilative, i.e.:   a ~~  For  Alternative' instances this property translates to: empty  a ~~ empty hAll right semirings must have a right-absorbative addititive sunit, however note that depending on the PrdF instance this does not preclude IEEE754-mandated behavior such as:    NaN ~~ NaN This is a required property.rings& must be a semiring homomorphism into R.This is a required property.rings; \forall a, b, c \in R: b + a \sim c + a \Rightarrow b = c If R1 is right-cancellative wrt addition then for all a the section (a <>) is injective.rings; \forall a, b, c \in R: b * a \sim c * a \Rightarrow b = c If R7 is right-cancellative wrt multiplication then for all a the section (a ><) is injective.rings& \forall a, b \in R: a + b \sim b + a rings& \forall a, b \in R: a * b \sim b * a rings\ \forall M \geq 0; a_1 \dots a_M, b \in R: (\sum_{i=1}^M a_i) * b \sim \sum_{i=1}^M a_i * b R: must right-distribute multiplication between finite sums.2For types with exact arithmetic this follows from  distributive & neutral_multiplication.rings\ \forall M \geq 1; a_1 \dots a_M, b \in R: (\sum_{i=1}^M a_i) * b \sim \sum_{i=1}^M a_i * b RC must right-distribute multiplication over finite (non-empty) sums.2For types with exact arithmetic this follows from  distributive and the universality of .rings \forall M,N \geq 0; a_1 \dots a_M, b_1 \dots b_N \in R: (\sum_{i=1}^M a_i) * (\sum_{j=1}^N b_j) \sim \sum_{i=1 j=1}^{i=M j=N} a_i * b_j If RA is also left-distributive then it supports cross-multiplication.rings \forall M,N \geq 1; a_1 \dots a_M, b_1 \dots b_N \in R: (\sum_{i=1}^M a_i) * (\sum_{j=1}^N b_j) = \sum_{i=1 j=1}^{i=M j=N} a_i * b_j If RM is also left-distributive then it supports (non-empty) cross-multiplication. Safe =?@AXkrings& is a preordered relation relative to .This is a required property.rings" is a minimal or least element of r.This is a required property.rings4( forall a, b, c: b leq c Rightarrow b + a leq c + aDIn an ordered semiring this follows directly from the definition of .Compare cancellative_addition.This is a required property.rings8 \forall a, b: a + b = 0 \Rightarrow a = 0 \wedge b = 0 This is a required property.rings4( forall a, b, c: b leq c Rightarrow b * a leq c * a2In an ordered semiring this follows directly from  distributive and the definition of .Compare cancellative_multiplication.This is a required property.rings# is consistent with annihilativity.OThis means that a dioid with an annihilative multiplicative sunit must satisfy: (one <~) "a (one ==) rings+( forall a, b: a leq b Rightarrow a + b = brings6 \forall a, b: a * b = 0 \Rightarrow a = 0 \vee b = 0 rings# \forall a, b \in R: a * b + b = b BRight-additive absorbativity is a generalized form of idempotency:   a ~~ a <> a ~~ a rings# \forall a, b \in R: b + b * a = b ALeft-additive absorbativity is a generalized form of idempotency:   a ~~ a <> a ~~ a rings% \forall a, b \in R: (a + b) * b = b HRight-mulitplicative absorbativity is a generalized form of idempotency:   a ~~ a  a ~~ a See  ,https://en.wikipedia.org/wiki/Absorption_law.rings% \forall a, b \in R: b * (b + a) = b GLeft-mulitplicative absorbativity is a generalized form of idempotency:   a ~~ a  a ~~ a See  ,https://en.wikipedia.org/wiki/Absorption_law.rings \forall a \in R: o + a = o MA unital semiring with a right-annihilative muliplicative sunit must satisfy:  <> a ~~  "For a dioid this is equivalent to: ( ) ~~ ( ) For  Alternative/ instances this is known as the left-catch law:  a <|> _ ~~  a rings \forall a \in R: a + o = o LA unital semiring with a left-annihilative muliplicative sunit must satisfy: a   ~~  Note that the left-annihilative property is too strong for many instances. This is because it requires that any effects that r generates be undsunit.See  0https://winterkoninkje.dreamwidth.org/90905.html.rings= \forall a, b, c \in R: c + (a * b) \equiv (c + a) * (c + b) MA right-codistributive semiring has a right-annihilative muliplicative sunit:    a  ~~  ~~   aidempotent mulitiplication:     a ~~ a ~~ a  aand idempotent addition:   a  a ~~ a ~~ a  aFurthermore if R8 is commutative then it is a right-distributive lattice.rings3 1 + \sum_{i=1}^{P+1} a^i = 1 + \sum_{i=1}^{P} a^i If a is p-stable for some p, then we have:  p a ~~ a   p a   ~~  p a  a   If  and / are idempotent then every element is 1-stable:  a  a  a   = a  a   = a  rings< x = a * x + b \Rightarrow x = (1 + \sum_{i=1}^{P} a^i) * b If a is p-stable for some p, then we have:rings% \forall a \in R : a^* = a^* * a + 1  Closure is p-stability for all a in the limit as  p \to \infinity .KOne way to think of this property is that all geometric series "converge":1 \forall a \in R : 1 + \sum_{i \geq 1} a^i \in R  Safe =?@AXk !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~   $rings-0.0.2.1-2cNOHb8Tu43JSXEzHbusui Data.RingData.Complex.Instance Data.Group Data.SemiringData.Int.InstanceData.Float.InstanceData.Fixed.InstanceData.Double.Instance Data.DioidData.Bool.InstanceData.Semiring.PropertyData.Dioid.PropertyData.Word.Instance Data.MonoidProductDatafoldr' Data.List replicatePropertyWarningbaseGHC.Base<>$fMonoidComplex$fSemigroupComplexGroupnegate<<$fGroupComplexProdgetProdKleenestarplusSemiring>< fromBooleansunitfromBooleanDefproductproduct1crosscross1 replicate'^powers$fSemiringIntMap $fSemiringMap $fSemiringSeq $fSemiringSet$fSemiringEquivalence$fSemiringPredicate $fSemiringIO $fSemiringAll $fSemiringAny$fSemiringIdentity$fSemiringConst$fSemiringDual$fSemiringMaybe $fSemiring[]$fSemiringComplex $fSemiring(,) $fSemiringOp $fSemiring->$fSemiringOrdering $fSemiring()$fSemiringNonEmpty$fSemiringEither $fSemiringMin $fSemiringMax$fSemiringLast$fSemiringFirst $fKleene-> $fKleene() $fMonoidProd$fSemigroupProd$fApplicativeProd$fEqProd $fOrdProd $fShowProd $fBoundedProd $fGenericProd$fGeneric1Prod $fFunctorProdRingabssignum $fRingInteger $fRingInt64 $fRingInt32 $fRingInt16 $fRingInt8 $fRingInt$fSemiringInteger$fSemiringInt64$fSemiringInt32$fSemiringInt16$fSemiringInt8 $fSemiringInt$fGroupInteger $fGroupInt64 $fGroupInt32 $fGroupInt16 $fGroupInt8 $fGroupInt$fMonoidInteger $fMonoidInt64 $fMonoidInt32 $fMonoidInt16 $fMonoidInt8 $fMonoidInt$fSemigroupInteger$fSemigroupInt64$fSemigroupInt32$fSemigroupInt16$fSemigroupInt8$fSemigroupInt$fSemiringCFloat$fSemiringFloat$fMonoidCFloat $fMonoidFloat$fSemigroupCFloat$fSemigroupFloat $fRingFixed $fRingFixed0 $fRingFixed1 $fRingFixed2 $fRingFixed3 $fRingFixed4 $fRingFixed5$fSemiringFixed$fSemiringFixed0$fSemiringFixed1$fSemiringFixed2$fSemiringFixed3$fSemiringFixed4$fSemiringFixed5 $fGroupFixed $fGroupFixed0 $fGroupFixed1 $fGroupFixed2 $fGroupFixed3 $fGroupFixed4 $fGroupFixed5 $fMonoidFixed$fMonoidFixed0$fMonoidFixed1$fMonoidFixed2$fMonoidFixed3$fMonoidFixed4$fMonoidFixed5$fSemigroupFixed$fSemigroupFixed0$fSemigroupFixed1$fSemigroupFixed2$fSemigroupFixed3$fSemigroupFixed4$fSemigroupFixed5$fSemiringCDouble$fSemiringDouble$fMonoidCDouble$fMonoidDouble$fSemigroupCDouble$fSemigroupDoubleDioid Topological $fDioidBool $fKleeneBool$fSemiringBool $fMonoidBool$fSemigroupBoolneutral_addition_onneutral_addition_on'neutral_multiplication_onneutral_multiplication_on'associative_addition_onassociative_multiplication_ondistributive_on nonunital_onannihilative_multiplication_onhomomorphism_booleancancellative_addition_oncancellative_multiplication_oncommutative_addition_oncommutative_multiplication_ondistributive_finite_ondistributive_finite1_ondistributive_cross_ondistributive_cross1_onordered_preorderedordered_monotone_zeroordered_monotone_additionordered_positive_additionordered_monotone_multiplicationordered_annihilative_sunitordered_idempotent_additionordered_positive_multiplicationabsorbative_additionidempotent_additionabsorbative_addition'absorbative_multiplicationabsorbative_multiplication'annihilative_additionannihilative_addition'codistributivekleene_pstablekleene_paffine kleene_stable kleene_affineidempotent_star$fDioidNatural $fDioidWord64 $fDioidWord32 $fDioidWord16 $fDioidWord8 $fDioidWord$fSemiringNatural$fSemiringWord64$fSemiringWord32$fSemiringWord16$fSemiringWord8$fSemiringWord$fMonoidNatural$fMonoidWord64$fMonoidWord32$fMonoidWord16 $fMonoidWord8 $fMonoidWord$fSemigroupNatural$fSemigroupWord64$fSemigroupWord32$fSemigroupWord16$fSemigroupWord8$fSemigroupWordMonoidGHC.NumNummempty*connections-0.0.2.1-409JT1VTQIKEBkLJX6J8hVData.Prd<~ghc-prim GHC.TypesTrue=~ GHC.Classes== Semigroup*>)semigroupoids-5.3.4-w5wpvXNssmA4BCVoX2GwVData.Semigroup.Foldable.Classfold1~~pure