Monoid
Combinators
Signature
declare function array<A>(): Monoid<readonly Array<A>>The dual of a Monoid, obtained by swapping the arguments of combine.
Signature
declare function reverse<A>(M: Monoid<A>): Monoid<A>;This function creates and returns a new Monoid for a struct of values based on the given Monoids for each property in the struct. The returned Monoid combines two structs of the same type by applying the corresponding Monoid passed as arguments to each property in the struct.
The empty value of the returned Monoid is a struct where each property is the empty value of the corresponding Monoid in the input monoids object.
It is useful when you need to combine two structs of the same type and you have a specific way of combining each property of the struct.
Signature
declare function struct<
R extends {
[x: string]: Monoid<any>;
},
>(fields: R): Monoid<{ [K in string | number | symbol]: [R[K]] extends [Monoid<A>] ? A : never }>;Similar to Promise.all but operates on Monoids.
This function creates and returns a new Monoid for a tuple of values based on the given Monoids for each element in the tuple. The returned Monoid combines two tuples of the same type by applying the corresponding Monoid passed as arguments to each element in the tuple.
The empty value of the returned Monoid is the tuple of empty values of the input Monoids.
It is useful when you need to combine two tuples of the same type and you have a specific way of combining each element of the tuple.
Signature
declare function tuple<T extends readonly Array<Monoid<any>>>(...elements: T): Monoid<{ [I in string | number | symbol]: [T[I]] extends [Monoid<A>] ? A : never }>Constructors
fromSemigroup
Signature
declare function fromSemigroup<A>(S: Semigroup<A>, empty: A): Monoid<A>;Get a monoid where combine will return the maximum, based on the provided bounded order.
The empty value is the minimum value.
Signature
declare function max<A>(B: Bounded<A>): Monoid<A>;Get a monoid where combine will return the minimum, based on the provided bounded order.
The empty value is the maxBound value.
Signature
declare function min<A>(B: Bounded<A>): Monoid<A>;
Given a type
A, this function creates and returns aSemigroupforReadonlyArray<A>.The
emptyvalue is the empty array.