# Monoid

### From HaskellWiki

(Difference between revisions)

RossPaterson (Talk | contribs) (egs, introduce refs) |
RossPaterson (Talk | contribs) (refer to uses) |
||

Line 7: | Line 7: | ||

* sets under union |
* sets under union |
||

* functions from a type to itself, under composition |
* functions from a type to itself, under composition |
||

+ | |||

+ | A Monoid class is defined in [http://www.haskell.org/ghc/dist/current/docs/libraries/base/Data-Monoid.html Data.Monoid], and used in [http://www.haskell.org/ghc/dist/current/docs/libraries/base/Data-Foldable.html Data.Foldable] and in the Writer monad. |
||

The monoid interface enables a number of algorithms, including parallel algorithms and tree searches, e.g.: |
The monoid interface enables a number of algorithms, including parallel algorithms and tree searches, e.g.: |
||

− | * The [http://www.haskell.org/ghc/dist/current/docs/libraries/base/Data-Monoid.html Data.Monoid] module |
||

* An introduction: [http://sigfpe.blogspot.com/2009/01/haskell-monoids-and-their-uses.html Haskell Monoids and their Uses] |
* An introduction: [http://sigfpe.blogspot.com/2009/01/haskell-monoids-and-their-uses.html Haskell Monoids and their Uses] |
||

* The blog article [http://apfelmus.nfshost.com/monoid-fingertree.html Monoids and Finger Trees] |
* The blog article [http://apfelmus.nfshost.com/monoid-fingertree.html Monoids and Finger Trees] |

## Revision as of 13:58, 28 January 2009

*This article is a stub. You can help by expanding it.*

A monoid is an algebraic structure with an associative binary operation that has an identity element. Examples include:

- lists under concatenation
- numbers under addition or multiplication
- Booleans under conjunction or disjunction
- sets under union
- functions from a type to itself, under composition

A Monoid class is defined in Data.Monoid, and used in Data.Foldable and in the Writer monad.

The monoid interface enables a number of algorithms, including parallel algorithms and tree searches, e.g.:

- An introduction: Haskell Monoids and their Uses
- The blog article Monoids and Finger Trees
- Monad.Reader issue 11, "How to Refold a Map." (PDF), and a follow up

Generalizations of monoids feature in Category theory, for example: