The tropical semiring.
Tropical 'Minima a is equivalent to the semiring
(a \cup \{+\infty\}, \oplus, \otimes) , where x \oplus y = min\{x,y\} and x \otimes y = x + y.
Tropical 'Maxima a is equivalent to the semiring
(a \cup \{-\infty\}, \oplus, \otimes) , where x \oplus y = max\{x,y\} and x \otimes y = x + y.
In literature, the Semiring instance of the Tropical semiring lifts
the underlying semiring's additive structure. One might ask why this lifting doesn't
instead witness a Monoid, since we only lift zero and plus - the reason is
that usually the additive structure of a semiring is monotonic, i.e.
a + (min b c) == min (a + b) (a + c), but in general this is not true.
For example, lifting Product Word into Tropical is lawful,
but Product Int is not, lacking distributivity: (-1) * (min 0 1) /= min ((-1) * 0) ((-1) * 1).
So, we deviate from literature and instead
witness the lifting of a Monoid, so the user must take care to ensure
that their implementation of mappend is monotonic.
Instances7Eq, Data, Ord, Read, Show, Semiring, …
Eq a => Eq (Tropical e a)Defined in semirings-0.7 · Data.Semiring.Tropical(Typeable e, Data a) => Data (Tropical e a)Defined in semirings-0.7 · Data.Semiring.Tropical(Ord a, Extremum e) => Ord (Tropical e a)Defined in semirings-0.7 · Data.Semiring.TropicalRead a => Read (Tropical e a)Defined in semirings-0.7 · Data.Semiring.TropicalShow a => Show (Tropical e a)Defined in semirings-0.7 · Data.Semiring.Tropical(Ord a, Monoid a, Extremum e) => Semiring (Tropical e a)Defined in semirings-0.7 · Data.Semiring.Tropical(Ord a, Monoid a, Extremum e) => Star (Tropical e a)Defined in semirings-0.7 · Data.Semiring.Tropical