-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | A module for dealing with semirings.
--   
--   Semirings are like normal rings, except you can't subtract. This
--   library provides a type class for semirings.
@package semiring-simple
@version 1.0.0.1


-- | This library provides a type class for semirings.
--   
--   A semiring is an additive commutative monoid with identity
--   <a>zero</a>:
--   
--   Most Haskellers are familiar with the <a>Monoid</a> typeclass:
--   
--   <pre>
--        zero &lt;+&gt; a ≡ a
--   (a &lt;+&gt; b) &lt;+&gt; c ≡ a &lt;+&gt; (b &lt;+&gt; c)
--   </pre>
--   
--   In this case, we've aliased
--   
--   <pre>
--   zero = mempty
--   (&lt;+&gt;) = mappend
--   </pre>
--   
--   A commutative monoid adds the requirement of symmetry:
--   
--   <pre>
--   a &lt;+&gt; b ≡ b &lt;+&gt; a
--   </pre>
--   
--   A semiring adds the requirement of a multiplication-like operator.
--   However, it does not require the existence of multiplicative inverses,
--   i.e. division. Moreover, multiplication does not need to be
--   commutative.
--   
--   <pre>
--         one &lt;.&gt; a ≡ a
--         a &lt;.&gt; one ≡ a
--   (a &lt;.&gt; b) &lt;.&gt; c ≡ a &lt;.&gt; (b &lt;.&gt; c)
--   </pre>
--   
--   Multiplication distributes over addition:
--   
--   <pre>
--   a &lt;.&gt; (b &lt;+&gt; c) ≡ (a &lt;.&gt; b) &lt;+&gt; (a &lt;.&gt; b)
--   (a &lt;+&gt; b) &lt;&gt;. c ≡ (a &lt;.&gt; c) &lt;+&gt; (b &lt;.&gt; c)
--   </pre>
--   
--   <a>zero</a> annihilates a semiring with respect to multiplication:
--   
--   <pre>
--   zero &lt;.&gt; a ≡ zero
--   a &lt;.&gt; zero ≡ zero
--   </pre>
--   
--   The classic example of a semiring is the "Tropical numbers". The
--   Tropical numbers, or T, are just real numbers with different
--   operators.
--   
--   <pre>
--   zero = ∞
--   a &lt;+&gt; b = minimum {a, b}
--   one = 0
--   a &lt;.&gt; b = a + b
--   </pre>
--   
--   We can easily verify that these satisfy the semiring axioms:
--   
--   First, the requirements for a commutative monoid
--   
--   <pre>
--               minimum {∞, a} ≡ minimum {a, ∞} ≡ a
--               minimum {a, ∞} ≡ a
--               minimum {a, b} ≡ minimum {b, a}
--   minimum {a, minimum{b, c}} ≡ minimum {minimum {a, b}, c}
--   </pre>
--   
--   <pre>
--                0 + a ≡ a
--                a + 0 ≡ a
--          a + (b + c) ≡ (a + b) + c
--   a + minimum {b, c} ≡ minimum {a + b, a + c}
--   minimum {a, b} + c ≡ minimum {a + c, b + c}
--                a + ∞ ≡ ∞
--                ∞ + a ≡ ∞
--   </pre>
module Data.Semiring

-- | Alias for <a>mappend</a>.
(<+>) :: Monoid m => m -> m -> m
infixl 5 <+>

-- | Alias for <a>mempty</a>
zero :: Monoid m => m
class Monoid m => Semiring m
one :: Semiring m => m
(<.>) :: Semiring m => m -> m -> m
