← Back

Source

Semigroup

``````interface Semigroup<A> {
readonly concat: (x: A, y: A) => A
}
``````

semigroupAll

``````Semigroup<boolean>
``````

Boolean semigroup under conjunction

semigroupAny

``````Semigroup<boolean>
``````

Boolean semigroup under disjunction

semigroupProduct

``````Semigroup<number>
``````

Number Semigroup under multiplication

semigroupString

``````Semigroup<string>
``````

semigroupSum

``````Semigroup<number>
``````

semigroupVoid

``````Semigroup<void>
``````

fold

``````<A>(S: Semigroup<A>) => (a: A) => (as: Array<A>): A
``````

getArraySemigroup

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

Semigroup under array concatenation

getDictionarySemigroup

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

Gets Semigroup instance for dictionaries given Semigroup instance for their values

Example

``````import { getDictionarySemigroup, semigroupSum } from 'fp-ts/lib/Semigroup'

const S = getDictionarySemigroup(semigroupSum)
assert.deepEqual(S.concat({ foo: 123 }, { foo: 456 }), { foo: 579 })
``````

getDualSemigroup

``````<A>(S: Semigroup<A>): Semigroup<A>
``````

getFirstSemigroup

``````<A = never>(): Semigroup<A>
``````

getFunctionSemigroup

``````<S>(S: Semigroup<S>) => <A = never>(): Semigroup<(a: A) => S>
``````

getJoinSemigroup

``````<A>(O: Ord<A>): Semigroup<A>
``````

getLastSemigroup

``````<A = never>(): Semigroup<A>
``````

getMeetSemigroup

``````<A>(O: Ord<A>): Semigroup<A>
``````

getObjectSemigroup

``````<A extends object = never>(): Semigroup<A>
``````

Gets Semigroup instance for objects of given type preserving their type

Example

``````import { getObjectSemigroup } from 'fp-ts/lib/Semigroup'

const S = getObjectSemigroup<{ foo: number }>()
assert.deepEqual(S.concat({ foo: 123 }, { foo: 456 }), { foo: 456 })
``````

getProductSemigroup

``````<A, B>(SA: Semigroup<A>, SB: Semigroup<B>): Semigroup<[A, B]>
``````

``````<O extends { [key: string]: any }>(