semigroups-0.5.0: Haskell 98 semigroups

Portabilityportable
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>

Data.Semigroup

Contents

Description

 

Synopsis

Documentation

class Semigroup a whereSource

Methods

(<>) :: a -> a -> aSource

sconcat :: NonEmpty a -> aSource

Semigroups

newtype Min a Source

Constructors

Min 

Fields

getMin :: a
 

newtype Max a Source

Constructors

Max 

Fields

getMax :: a
 

newtype First a Source

Use Option (First a) -- to get the behavior of Data.Monoid.First

Constructors

First 

Fields

getFirst :: a
 

newtype Last a Source

Use Option (Last a) -- to get the behavior of Data.Monoid.Last

Constructors

Last 

Fields

getLast :: a
 

newtype WrappedMonoid m Source

Constructors

WrapMonoid 

Fields

unwrapMonoid :: m
 

Monoids from Data.Monoid

newtype Dual a

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

Constructors

Dual 

Fields

getDual :: a
 

newtype Endo a

The monoid of endomorphisms under composition.

Constructors

Endo 

Fields

appEndo :: a -> a
 

newtype All

Boolean monoid under conjunction.

Constructors

All 

Fields

getAll :: Bool
 

newtype Any

Boolean monoid under disjunction.

Constructors

Any 

Fields

getAny :: Bool
 

newtype Sum a

Monoid under addition.

Constructors

Sum 

Fields

getSum :: a
 

newtype Product a

Monoid under multiplication.

Constructors

Product 

Fields

getProduct :: a
 

A better monoid for Maybe

newtype Option a Source

Option is effectively Maybe with a better instance of Monoid, built off of an underlying Semigroup instead of an underlying Monoid. Ideally, this type would not exist at all and we would just fix the Monoid intance of Maybe

Constructors

Option 

Fields

getOption :: Maybe a
 

option :: b -> (a -> b) -> Option a -> bSource

Difference lists of a semigroup

diff :: Semigroup m => m -> Endo mSource

This lets you use a difference list of a Semigroup as a Monoid.