úÎ!lgfË_      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^Safe=?@AXkêringsA  is a _ plus a function,  , such that:  a << negate a == mempty negate a << a == mempty6Safe=?@AXk‹Safe 47=?@AXk.h rings Monoid under . Analogous to , but uses the  constraint, rather than `.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 c)< (b >< c)]A non-unital right semiring (sometimes referred to as a bimonoid) is a pre-semiring with a aJ element that is neutral with respect to both addition and multiplication.NA unital right semiring is a pre-semiring with two distinct neutral elements, a and  , such that a is right-neutral wrt addition, , is right-neutral wrt multiplication, and a+ is right-annihilative wrt multiplication.  Note that  needn't be distinct from a.>Instances also need not be commutative nor 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 <> 421KFor semirings without a distinct multiplicative unit 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-Fold with no additive or multiplicative unit.rings!Fold with no multiplicative unit.rings*Fold with additive & multiplicative units.?This function will zero out if there is no multiplicative unit.ringsA generalization of   to an arbitrary _.  Adapted from  Jhttp://augustss.blogspot.com/2008/07/lost-and-found-if-i-write-108-in.html.?rings1'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} ! ! 8Safe=?@AXk/‰JLKJLKSafe =?@AXkf7Mrings! \forall a \in R: (z + a) \sim a AA (pre-)semiring with a right-neutral additive unit must satisfy: neutral_addition a ~~ const True Or, equivalently: a b r ~~ r This is a required property.Orings! \forall a \in R: (o * a) \sim a GA (pre-)semiring with a right-neutral multiplicative unit must satisfy: neutral_multiplication  ~~ const True Or, equivalently:   r ~~ r This is a required property.Qrings5 \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 c2 instance, but is included here for completeness.This is a required property.Rrings5 \forall a, b, c \in R: (a * b) * c \sim a * (b * c) R% must right-associate multiplication.This is a required property.Srings; \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) d c = (a d c) <|> (b d c) See  ?https://en.wikibooks.org/wiki/Haskell/Alternative_and_MonadPlus.This is a required property.Trings* \forall a, b \in R: a * b \sim a * b + b If R is non-unital (i.e. unit 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.Urings! \forall a \in R: (z * a) \sim u A RE is unital then its addititive unit must be right-annihilative, i.e.: a  a ~~ a For  Alternative' instances this property translates to: empty d a ~~ empty gAll right semirings must have a right-absorbative addititive unit, however note that depending on the PrdF instance this does not preclude IEEE754-mandated behavior such as:  a  NaN ~~ NaN This is a required property.Vrings& must be a semiring homomorphism into R.This is a required property.Wrings; \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.Xrings; \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.Yrings& \forall a, b \in R: a + b \sim b + a Zrings& \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 e.]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.MNOPQRSTUVWXYZ[\]^MNOPQRSTUVWXYZ[\]^f  !"#$%&'() *+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkljmnjkojkpjkqjkrstuv"rings-0.0.1-ENwDaj1sjwXLe2A9n0ZKRO Data.GroupData.Semigroup.Orphan Data.Semiring Data.RingData.Semiring.Property Data.MonoidProductDatafoldr' Data.List replicateWarningGroupnegate<<$fMonoidNatural$fSemigroupNatural$fMonoidComplex$fSemigroupComplex $fMonoidFloat$fSemigroupFloat $fMonoidBool$fSemigroupBool $fMonoidInt$fSemigroupInt $fMonoidWord$fSemigroupWordProdgetProdSemiring>< fromBooleanunitfromBooleanDefproductproduct1crosscross1foldPresemiring foldNonunital foldUnital replicate'^powers$fSemiringIntMap $fSemiringMap $fSemiringSeq $fSemiringSet$fSemiringComparison$fSemiringEquivalence$fSemiringPredicate $fSemiringIO $fSemiringAll $fSemiringAny$fSemiringIdentity$fSemiringConst$fSemiringDual$fSemiringMaybe $fSemiring[] $fSemiring(,) $fSemiringOp $fSemiring->$fSemiringWord $fSemiringInt$fSemiringNatural$fSemiringBool$fSemiringOrdering $fSemiring()$fSemiringNonEmpty$fSemiringEither $fSemiringMin $fSemiringMax$fSemiringLast$fSemiringFirst $fMonoidProd$fSemigroupProd$fApplicativeProd$fEqProd $fOrdProd $fShowProd $fBoundedProd $fGenericProd$fGeneric1Prod $fFunctorProdRingabssignumneutral_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_onbaseGHC.BaseMonoidGHC.NumNummempty<> Semigroup*>*semigroupoids-5.3.3-EESwn4HgBKpKioxEXkvG0jData.Semigroup.Foldable.Classfold1