A class for monoids (types with an associative binary operation that has an identity) with various general-purpose instances.
The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following laws:
* append mempty x =
* append x mempty =
* append x (mappend y z) = mappend (mappend x y)
* concat = foldr mappend memp
The method names refer to the monoid of lists under concatenation, but there are many other instances.
Minimal complete definition: mempty and mappend.
Some types can be viewed as a monoid in more than one way, e.g. both addition and multiplication on numbers. In such cases we often define newtypes and make those instances of Monoid, e.g. Sum and Product.
Various extra monoid-related definitions and utilities, such as monoid actions, monoid coproducts, "deletable" monoids, "split" monoids, and "cut" monoids.
a practical monoid implementation
Small module with utility function and class for modifying record fields of a monoidal type.
Monoids for calculation of statistics of sample. This approach allows to calculate many statistics in one pass over data and possibility to parallelize calculations. However not all statistics could be calculated this way.
This packages is quite similar to monoids package but limited to calculation on statistics. In particular it makes use of commutatitvity of statistical monoids.
* 0.3.1 Better documentation; Fix in Min/Max monoids
This package defines a hierarchy of subclasses of Monoid together with their instances for all data structures from base, containers, and text packages.
Monoid transformers: State, Reader
There is no Writer transformer. It's vice versa: The Writer monad transforms a monoid to a monad.
The HoleyMonoid allows building monoidal values of which certain components are to be filled in later. For example:
> > let holey = now "x = "
> . later show
> . now ", y = "
> . later show
> > run holey 3 5
> "x = 3, y = 5"
A polyvariadic function takes an indefinite number of possibly differently typed parameters. polyToMonoid provides two polyvariadic functions that map their parameters into a given monoid.