Overview
See Getting started with fp-ts: Semigroup
Table of contents
- Semigroup (interface)
- semigroupAll (constant)
- semigroupAny (constant)
- semigroupProduct (constant)
- semigroupString (constant)
- semigroupSum (constant)
- semigroupVoid (constant)
- fold (function)
getArraySemigroup(function)getDictionarySemigroup(function)- getDualSemigroup (function)
- getFirstSemigroup (function)
- getFunctionSemigroup (function)
- getJoinSemigroup (function)
- getLastSemigroup (function)
- getMeetSemigroup (function)
- getObjectSemigroup (function)
getProductSemigroup(function)getRecordSemigroup(function)- getStructSemigroup (function)
- getTupleSemigroup (function)
Semigroup (interface)
Signature
export interface Semigroup<A> {
readonly concat: (x: A, y: A) => A
}
Added in v1.0.0
semigroupAll (constant)
Boolean semigroup under conjunction
Signature
export const semigroupAll: Semigroup<boolean> = ...
Added in v1.0.0
semigroupAny (constant)
Boolean semigroup under disjunction
Signature
export const semigroupAny: Semigroup<boolean> = ...
Added in v1.0.0
semigroupProduct (constant)
Number Semigroup
under multiplication
Signature
export const semigroupProduct: Semigroup<number> = ...
Added in v1.0.0
semigroupString (constant)
Signature
export const semigroupString: Semigroup<string> = ...
Added in v1.0.0
semigroupSum (constant)
Number Semigroup
under addition
Signature
export const semigroupSum: Semigroup<number> = ...
Added in v1.0.0
semigroupVoid (constant)
Signature
export const semigroupVoid: Semigroup<void> = ...
Added in v1.0.0
fold (function)
Signature
export const fold = <A>(S: Semigroup<A>) => (a: A) => (as: Array<A>): A => ...
Added in v1.0.0
getArraySemigroup (function)
Use Monoid
’s getArrayMonoid
instead
Signature
export const getArraySemigroup = <A = never>(): Semigroup<Array<A>> => ...
Added in v1.0.0
getDictionarySemigroup (function)
Use Record
’s getMonoid
Signature
export function getDictionarySemigroup<K extends string, A>(S: Semigroup<A>): Semigroup<Record<K, A>>
export function getDictionarySemigroup<A>(S: Semigroup<A>): Semigroup<{ [key: string]: A }> { ... }
Added in v1.4.0
getDualSemigroup (function)
Signature
export const getDualSemigroup = <A>(S: Semigroup<A>): Semigroup<A> => ...
Added in v1.0.0
getFirstSemigroup (function)
Signature
export const getFirstSemigroup = <A = never>(): Semigroup<A> => ...
Added in v1.0.0
getFunctionSemigroup (function)
Signature
export const getFunctionSemigroup = <S>(S: Semigroup<S>) => <A = never>(): Semigroup<(a: A) => S> => ...
Added in v1.0.0
getJoinSemigroup (function)
Signature
export const getJoinSemigroup = <A>(O: Ord<A>): Semigroup<A> => ...
Added in v1.0.0
getLastSemigroup (function)
Signature
export const getLastSemigroup = <A = never>(): Semigroup<A> => ...
Added in v1.0.0
getMeetSemigroup (function)
Signature
export const getMeetSemigroup = <A>(O: Ord<A>): Semigroup<A> => ...
Added in v1.0.0
getObjectSemigroup (function)
Returns a Semigroup
instance for objects preserving their type
Signature
export const getObjectSemigroup = <A extends object = never>(): Semigroup<A> => ...
Example
import { getObjectSemigroup } from 'fp-ts/lib/Semigroup'
interface Person {
name: string
age: number
}
const S = getObjectSemigroup<Person>()
assert.deepStrictEqual(S.concat({ name: 'name', age: 23 }, { name: 'name', age: 24 }), { name: 'name', age: 24 })
Added in v1.4.0
getProductSemigroup (function)
Use getTupleSemigroup
instead
Signature
export const getProductSemigroup = <A, B>(SA: Semigroup<A>, SB: Semigroup<B>): Semigroup<[A, B]> => ...
Added in v1.0.0
getRecordSemigroup (function)
Use getStructSemigroup
instead
Signature
export const getRecordSemigroup = <O extends { [key: string]: any }>(
semigroups: { [K in keyof O]: Semigroup<O[K]> }
): Semigroup<O> => ...
Added in v1.0.0
getStructSemigroup (function)
Signature
export const getStructSemigroup = <O extends { [key: string]: any }>(
semigroups: { [K in keyof O]: Semigroup<O[K]> }
): Semigroup<O> => ...
Added in v1.14.0
getTupleSemigroup (function)
Signature
export const getTupleSemigroup = <A, B>(SA: Semigroup<A>, SB: Semigroup<B>): Semigroup<[A, B]> => ...
Added in v1.14.0