| Haskell Hierarchical Libraries (base package) | Source code | Contents | Index

Data.Monoid |

Portability | portable
Stability | experimental
Maintainer | libraries@haskell.org

Description
The Monoid class with various general-purpose instances. Inspired by the paper Functional Programming with Overloading and Higher-Order Polymorphism, Mark P Jones (http://www.cse.ogi.edu/~mpj/) Advanced School of Functional Programming, 1995.
Synopsis

class Monoid a where

mempty :: a
mappend :: a -> a -> a
mconcat :: [a] -> a

newtype Dual a = Dual {

getDual :: a

}
newtype Endo a = Endo {

appEndo :: (a -> a)

}
newtype All = All {

getAll :: Bool

}
newtype Any = Any {

getAny :: Bool

}
newtype Sum a = Sum {

getSum :: a

}
newtype Product a = Product {

getProduct :: a

}

Documentation
class Monoid a where

The monoid class. A minimal complete definition must supply `mempty` and `mappend`, and these should satisfy the monoid laws.
Methods

mempty :: a
Identity of `mappend`
mappend :: a -> a -> a
An associative operation
mconcat :: [a] -> a
Fold a list using the monoid. For most types, the default definition for `mconcat` will be used, but the function is included in the class definition so that an optimized version can be provided for specific types.

Instances

Monoid All
Monoid Any
Monoid ByteString
Monoid ByteString
Monoid IntSet
Monoid Ordering
Monoid ()
(Monoid a, Monoid b) => Monoid (a, b)
(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c)
(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d)
(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e)
Monoid b => Monoid (a -> b)
Monoid a => Monoid (Dual a)
Monoid (Endo a)
Monoid (IntMap a)
Num a => Monoid (Product a)
Monoid (Seq a)
Ord a => Monoid (Set a)
Num a => Monoid (Sum a)
Monoid [a]
Ord k => Monoid (Map k v)

newtype Dual a

The dual of a monoid, obtained by swapping the arguments of `mappend`.
Constructors

Dual |

getDual :: a |

Instances

Monoid a => Monoid (Dual a)

newtype Endo a

The monoid of endomorphisms under composition.
Constructors

Endo |

appEndo :: (a -> a) |

Instances

Monoid (Endo a)

newtype All

Boolean monoid under conjunction.
Constructors

All |

getAll :: Bool |

Instances

Bounded All
Eq All
Monoid All
Ord All
Read All
Show All

newtype Any

Boolean monoid under disjunction.
Constructors

Any |

getAny :: Bool |

Instances

Bounded Any
Eq Any
Monoid Any
Ord Any
Read Any
Show Any

newtype Sum a

Monoid under addition.
Constructors

Sum |

getSum :: a |

Instances

Bounded a => Bounded (Sum a)
Eq a => Eq (Sum a)
Num a => Monoid (Sum a)
Ord a => Ord (Sum a)
Read a => Read (Sum a)
Show a => Show (Sum a)

newtype Product a

Monoid under multiplication.
Constructors

Product |

getProduct :: a |

Instances

Bounded a => Bounded (Product a)
Eq a => Eq (Product a)
Num a => Monoid (Product a)
Ord a => Ord (Product a)
Read a => Read (Product a)
Show a => Show (Product a)

Produced by Haddock version 0.8