| License | MIT |
|---|---|
| Maintainer | mail@doisinkidney.com |
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Semiring
Description
Documentation
class Semiring a where Source #
A Semiring is like the
the combination of two Monoids. The first
is called <+>; it has the identity element zero, and it is
commutative. The second is called <.>; it has identity element one,
and it must distribute over <+>.
Laws
Normal Monoid laws
(a
<+>b)<+>c = a<+>(b<+>c)zero<+>a = a<+>zero= a(a
<.>b)<.>c = a<.>(b<.>c)one<.>a = a<.>one= a
Commutativity of <+>
Distribution of <.> over <+>
Annihilation
Methods
The identity of <+>.
The identity of <.>.
(<.>) :: a -> a -> a infixl 7 Source #
An associative binary operation, which distributes over <+>.
(<+>) :: a -> a -> a infixl 6 Source #
An associative, commutative binary operation.
The identity of <+>.
The identity of <.>.
(<+>) :: Num a => a -> a -> a infixl 6 Source #
An associative, commutative binary operation.
(<.>) :: Num a => a -> a -> a infixl 7 Source #
An associative binary operation, which distributes over <+>.
Instances
Instances
| Monad Add Source # | |
| Functor Add Source # | |
| Applicative Add Source # | |
| Foldable Add Source # | |
| Generic1 Add Source # | |
| Bounded a => Bounded (Add a) Source # | |
| Enum a => Enum (Add a) Source # | |
| Eq a => Eq (Add a) Source # | |
| Num a => Num (Add a) Source # | |
| Ord a => Ord (Add a) Source # | |
| Read a => Read (Add a) Source # | |
| Show a => Show (Add a) Source # | |
| Generic (Add a) Source # | |
| Semiring a => Monoid (Add a) Source # | |
| Semiring a => Semiring (Add a) Source # | |
| type Rep1 Add Source # | |
| type Rep (Add a) Source # | |
Instances
| Monad Mul Source # | |
| Functor Mul Source # | |
| Applicative Mul Source # | |
| Foldable Mul Source # | |
| Generic1 Mul Source # | |
| Bounded a => Bounded (Mul a) Source # | |
| Enum a => Enum (Mul a) Source # | |
| Eq a => Eq (Mul a) Source # | |
| Num a => Num (Mul a) Source # | |
| Ord a => Ord (Mul a) Source # | |
| Read a => Read (Mul a) Source # | |
| Show a => Show (Mul a) Source # | |
| Generic (Mul a) Source # | |
| Semiring a => Monoid (Mul a) Source # | |
| Semiring a => Semiring (Mul a) Source # | |
| type Rep1 Mul Source # | |
| type Rep (Mul a) Source # | |
The "Arctic"
or max-plus semiring. It is a semiring where:
<+> = max (represented by zero = ∞Nothing)
(over the inner value)
<.> = <+> (over the inner value)one = zero
Instances
| Monad Max Source # | |
| Functor Max Source # | |
| Applicative Max Source # | |
| Foldable Max Source # | |
| Generic1 Max Source # | |
| Eq a => Eq (Max a) Source # | |
| Ord a => Ord (Max a) Source # | |
| Read a => Read (Max a) Source # | |
| Show a => Show (Max a) Source # | |
| Generic (Max a) Source # | |
| Ord a => Monoid (Max a) Source # | |
| (Semiring a, Ord a) => Semiring (Max a) Source # | |
| type Rep1 Max Source # | |
| type Rep (Max a) Source # | |
The "Tropical" or
min-plus semiring. It is a semiring where:
<+> = min (represented by zero = -∞Nothing)
(over the inner value)
<.> = <+> (over the inner value)one = zero
Instances
| Monad Min Source # | |
| Functor Min Source # | |
| Applicative Min Source # | |
| Foldable Min Source # | |
| Generic1 Min Source # | |
| Eq a => Eq (Min a) Source # | |
| Ord a => Ord (Min a) Source # | |
| Read a => Read (Min a) Source # | |
| Show a => Show (Min a) Source # | |
| Generic (Min a) Source # | |
| Ord a => Monoid (Min a) Source # | |
| (Semiring a, Ord a) => Semiring (Min a) Source # | |
| type Rep1 Min Source # | |
| type Rep (Min a) Source # | |