semigroups-0.6.1: 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
 

Instances

Typeable1 Min 
Bounded a => Bounded (Min a) 
Eq a => Eq (Min a) 
Data a => Data (Min a) 
Ord a => Ord (Min a) 
Read a => Read (Min a) 
Show a => Show (Min a) 
(Ord a, Bounded a) => Monoid (Min a) 
Ord a => Semigroup (Min a) 

newtype Max a Source

Constructors

Max 

Fields

getMax :: a
 

Instances

Typeable1 Max 
Bounded a => Bounded (Max a) 
Eq a => Eq (Max a) 
Data a => Data (Max a) 
Ord a => Ord (Max a) 
Read a => Read (Max a) 
Show a => Show (Max a) 
(Ord a, Bounded a) => Monoid (Max a) 
Ord a => Semigroup (Max a) 

newtype First a Source

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

Constructors

First 

Fields

getFirst :: a
 

Instances

Typeable1 First 
Bounded a => Bounded (First a) 
Eq a => Eq (First a) 
Data a => Data (First a) 
Ord a => Ord (First a) 
Read a => Read (First a) 
Show a => Show (First a) 
Semigroup (First a) 

newtype Last a Source

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

Constructors

Last 

Fields

getLast :: a
 

Instances

Typeable1 Last 
Bounded a => Bounded (Last a) 
Eq a => Eq (Last a) 
Data a => Data (Last a) 
Ord a => Ord (Last a) 
Read a => Read (Last a) 
Show a => Show (Last a) 
Semigroup (Last a) 

Monoids from Data.Monoid

newtype Dual a

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

Constructors

Dual 

Fields

getDual :: a
 

Instances

Bounded a => Bounded (Dual a) 
Eq a => Eq (Dual a) 
Ord a => Ord (Dual a) 
Read a => Read (Dual a) 
Show a => Show (Dual a) 
Monoid a => Monoid (Dual a) 
Semigroup a => Semigroup (Dual a) 

newtype Endo a

The monoid of endomorphisms under composition.

Constructors

Endo 

Fields

appEndo :: a -> a
 

Instances

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
 

Instances

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

newtype Product a

Monoid under multiplication.

Constructors

Product 

Fields

getProduct :: a
 

Instances

Bounded a => Bounded (Product a) 
Eq a => Eq (Product a) 
Ord a => Ord (Product a) 
Read a => Read (Product a) 
Show a => Show (Product a) 
Num a => Monoid (Product a) 
Num a => Semigroup (Product 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.