Portability | portable (but instances use MPTCs) |
---|---|

Stability | experimental |

Maintainer | ekmett@gmail.com |

Safe Haskell | Safe-Infered |

When dealing with a `Ring`

or other structure, you often need a pair of
`Monoid`

instances that are closely related. Making a `newtype`

for one
is unsatisfying and yields an unnatural programming style.

A `Multiplicative`

is a `Monoid`

that is intended for use in a scenario
that can be extended to have another `Monoid`

slot in for addition. This
enables one to use common notation.

Any `Multiplicative`

can be turned into a `Monoid`

using the `Log`

wrapper.

Any `Monoid`

can be turned into a `Multiplicative`

using the `Exp`

wrapper.

Instances are supplied for common Monads of Monoids, in a fashion
which can be extended if the `Monad`

is a `MonadPlus`

to yield a `RightSemiNearRing`

Instances are also supplied for common Applicatives of Monoids, in a
fashion which can be extended if the `Applicative`

is `Alternative`

to
yield a `RightSemiNearRing`

# Documentation

class Multiplicative m whereSource

Multiplicative Int | |

Multiplicative Integer | |

Monoid m => Multiplicative [m] | |

Integral m => Multiplicative (Ratio m) | |

Monoid n => Multiplicative (IO n) | |

Monoid n => Multiplicative (ZipList n) | |

Multiplicative m => Multiplicative (Dual m) | |

Monoid m => Multiplicative (Maybe m) | |

Monoid m => Multiplicative (Seq m) | |

Multiplicative m => Multiplicative (Self m) | |

Monoid m => Multiplicative (Exp m) | |

Monoid m => Multiplicative (Const m a) | |

(Measured v m, Monoid m) => Multiplicative (FingerTree v m) | |

(Applicative f, Monoid a) => Multiplicative (Alt f a) | |

(Monad m, Monoid a) => Multiplicative (MonadSum m a) |

# Multiplicative to Monoid

Convert a `Multiplicative`

into a `Monoid`

. Mnemonic: `Log a + Log b = Log (a * b)`

Multiplicative m => Monoid (Log m) | |

MultiplicativeGroup g => Group (Log g) |

# Monoid to Multiplicative

Convert a `Monoid`

into a `Multiplicative`

. Mnemonic: `Exp a * Exp b = Exp (a + b)`

Monoid m => Multiplicative (Exp m) | |

Group g => MultiplicativeGroup (Exp g) |