Data.Monoid.Multiplicative
 Portability portable (but instances use MPTCs) Stability experimental Maintainer ekmett@gmail.com
 Contents Multiplicative Monoids Multiplicative to Monoid Monoid to Multiplicative
Description

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 LeftSemiNearRing

Instances are also supplied for common Applicatives of Monoids, in a fashion which can be extended if the Applicative is Alternative to yield a LeftSemiNearRing

Synopsis
class Multiplicative m where
 one :: m times :: m -> m -> m
one :: Multiplicative m => m
times :: Multiplicative m => m -> m -> m
data Log m = Log {
 getLog :: m
}
data Exp m = Exp {
 getExp :: m
}
Documentation
Multiplicative Monoids
 class Multiplicative m where Source
Methods
 one :: m Source
 times :: m -> m -> m Source
Instances
 one :: Multiplicative m => m Source
 times :: Multiplicative m => m -> m -> m Source
Multiplicative to Monoid
 data Log m Source
Convert a Multiplicative into a Monoid. Mnemonic: Log a + Log b = Log (a * b)
Constructors
Log
 getLog :: m
Instances
 Multiplicative m => Module Natural (Log m) Multiplicative m => RightModule Natural (Log m) Multiplicative m => LeftModule Natural (Log m) Multiplicative m => Monoid (Log m)
Monoid to Multiplicative
 data Exp m Source
Convert a Monoid into a Multiplicative. Mnemonic: Exp a * Exp b = Exp (a + b)
Constructors
Exp
 getExp :: m
Instances
 Monoid m => Multiplicative (Exp m)