← Back

Source

# Monoid

``````interface Monoid<A> extends Semigroup<A> {
}
``````

## monoidAll

``````Monoid<boolean>
``````

Boolean monoid under conjunction

## monoidAny

``````Monoid<boolean>
``````

Boolean monoid under disjunction

## monoidProduct

``````Monoid<number>
``````

Number monoid under multiplication

## monoidString

``````Monoid<string>
``````

## monoidSum

``````Monoid<number>
``````

## monoidVoid

``````Monoid<void>
``````

## unsafeMonoidArray

``````Monoid<Array<any>>
``````

## fold

``````<A>(M: Monoid<A>): ((as: Array<A>) => A)
``````

## getArrayMonoid

``````<A = never>(): Monoid<Array<A>>
``````

Monoid under array concatenation (`Array<any>`)

## getDictionaryMonoid

``````<A>(S: Semigroup<A>): Monoid<{ [key: string]: A }>
``````

Gets Monoid instance for dictionaries given Semigroup instance for their values

Example

``````import { getDictionaryMonoid, fold } from 'fp-ts/lib/Monoid'
import { semigroupSum } from 'fp-ts/lib/Semigroup'

const M = getDictionaryMonoid(semigroupSum)
assert.deepEqual(fold(M)([{ foo: 123 }, { foo: 456 }]), { foo: 579 })
``````

## getDualMonoid

``````<A>(M: Monoid<A>): Monoid<A>
``````

## getEndomorphismMonoid

``````<A = never>(): Monoid<Endomorphism<A>>
``````

## getFunctionMonoid

``````<M>(M: Monoid<M>) => <A = never>(): Monoid<(a: A) => M>
``````

## getJoinMonoid

``````<A>(B: Bounded<A>): Monoid<A>
``````

## getMeetMonoid

``````<A>(B: Bounded<A>): Monoid<A>
``````

## getProductMonoid

``````<A, B>(MA: Monoid<A>, MB: Monoid<B>): Monoid<[A, B]>
``````

## getRecordMonoid

``````<O extends { [key: string]: any }>(
monoids: { [K in keyof O]: Monoid<O[K]> }
): Monoid<O>
``````