monoids-0.1.36: Monoids, specialized containers and a general map/reduce frameworkSource codeContentsIndex
Data.Monoid.Multiplicative
Portabilityportable (but instances use MPTCs)
Stabilityexperimental
Maintainerekmett@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 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

Synopsis
module Data.Monoid.Additive
class Multiplicative m where
one :: m
times :: m -> m -> m
data Log m = Log {
getLog :: m
}
data Exp m = Exp {
getExp :: m
}
Documentation
module Data.Monoid.Additive
Multiplicative Monoids
class Multiplicative m whereSource
Methods
one :: mSource
times :: m -> m -> mSource
show/hide Instances
Multiplicative Int
Multiplicative Integer
Multiplicative Natural
Monoid m => Multiplicative ([] m)
Integral m => Multiplicative (Ratio m)
Monoid n => Multiplicative (IO n)
Monoid m => Multiplicative (Maybe m)
Monoid n => Multiplicative (ZipList n)
Multiplicative m => Multiplicative (Dual m)
Monoid n => Multiplicative (STM n)
Monoid m => Multiplicative (Identity m)
Multiplicative m => Multiplicative (Self m)
Multiplicative m => Multiplicative (FromString m)
Monoid m => Multiplicative (Exp m)
Num a => Multiplicative (FromNum a)
Bits a => Multiplicative (Boolean a)
(Bounded a, Enum a) => Multiplicative (BitSet a)
Ord a => Multiplicative (Priority a)
(Bounded a, Ord a) => Multiplicative (Order a)
Num a => Multiplicative (Tropical a)
Monoid n => Multiplicative (ST s n)
Monoid m => Multiplicative (Const m a)
Monoid n => Multiplicative (ST s n)
(Measured v m, Monoid m) => Multiplicative (FingerTree v m)
Monoid m => Multiplicative (Cont r m)
(Monoid w, Monoid m) => Multiplicative (Writer w m)
(Monoid w, Monoid m) => Multiplicative (Writer w m)
Monoid m => Multiplicative (State s m)
Monoid m => Multiplicative (State s m)
Monoid m => Multiplicative (Reader e m)
Multiplicative m => Multiplicative (ReducedBy m s)
(Applicative f, Monoid a) => Multiplicative (Alt f a)
(Monad m, Monoid a) => Multiplicative (MonadSum m a)
(Modular s a, Integral a) => Multiplicative (Mod a s)
(Monad m, Monoid n) => Multiplicative (ContT r m n)
(Monad m, Monoid w, Monoid n) => Multiplicative (WriterT w m n)
(Monad m, Monoid w, Monoid n) => Multiplicative (WriterT w m n)
(Monad m, Monoid n) => Multiplicative (StateT s m n)
(Monad m, Monoid n) => Multiplicative (StateT s m n)
(Monad m, Monoid n) => Multiplicative (ReaderT e m n)
Bimodule r m => Multiplicative (D s r m)
(Monoid w, Monoid m) => Multiplicative (RWS r w s m)
(Monoid w, Monoid m) => Multiplicative (RWS r w s m)
(Stream s m t, Monoid n) => Multiplicative (ParsecT s u m n)
(Monad m, Monoid w, Monoid n) => Multiplicative (RWST r w s m n)
(Monad m, Monoid w, Monoid n) => Multiplicative (RWST r w s m n)
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
show/hide Instances
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
show/hide Instances
Produced by Haddock version 2.4.2