<A extends ReadonlyArray<unknown>>(reducers: {
readonly [K in keyof A]: Reducer.Reducer<A[K]>
}): Reducer.Reducer<A>Creates a Reducer for a tuple shape by providing a Reducer for each
position. The initial value is derived from each position's
Reducer.initialValue. When reducing a collection of tuples, each element
is combined independently.
When to use
Use when you need to fold same-shape tuples by accumulating each position independently into one summary tuple.
Example (Reducing a collection of tuples)
import { Number, String, Tuple } from "effect"
const R = Tuple.makeReducer<readonly [number, string]>([
Number.ReducerSum,
String.ReducerConcat
])
const result = R.combineAll([
[1, "a"],
[2, "b"],
[3, "c"]
])
console.log(result) // [6, "abc"]export function function makeReducer<
A extends ReadonlyArray<unknown>
>(reducers: {
readonly [K in keyof A]: Reducer.Reducer<A[K]>
}): Reducer.Reducer<A>
Creates a Reducer for a tuple shape by providing a Reducer for each
position. The initial value is derived from each position's
Reducer.initialValue. When reducing a collection of tuples, each element
is combined independently.
When to use
Use when you need to fold same-shape tuples by accumulating each position
independently into one summary tuple.
Example (Reducing a collection of tuples)
import { Number, String, Tuple } from "effect"
const R = Tuple.makeReducer<readonly [number, string]>([
Number.ReducerSum,
String.ReducerConcat
])
const result = R.combineAll([
[1, "a"],
[2, "b"],
[3, "c"]
])
console.log(result) // [6, "abc"]
makeReducer<function (type parameter) A in makeReducer<A extends ReadonlyArray<unknown>>(reducers: { readonly [K in keyof A]: Reducer.Reducer<A[K]>; }): Reducer.Reducer<A>A extends interface ReadonlyArray<T>ReadonlyArray<unknown>>(
reducers: {
readonly [K in keyof A]: Reducer.Reducer<A[K]>
}
reducers: { readonly [function (type parameter) KK in keyof function (type parameter) A in makeReducer<A extends ReadonlyArray<unknown>>(reducers: { readonly [K in keyof A]: Reducer.Reducer<A[K]>; }): Reducer.Reducer<A>A]: import ReducerReducer.type Reducer.Reducer = /*unresolved*/ anyReducer<function (type parameter) A in makeReducer<A extends ReadonlyArray<unknown>>(reducers: { readonly [K in keyof A]: Reducer.Reducer<A[K]>; }): Reducer.Reducer<A>A[function (type parameter) KK]> }
): import ReducerReducer.type Reducer.Reducer = /*unresolved*/ anyReducer<function (type parameter) A in makeReducer<A extends ReadonlyArray<unknown>>(reducers: { readonly [K in keyof A]: Reducer.Reducer<A[K]>; }): Reducer.Reducer<A>A> {
const const combine: anycombine = function makeCombiner<
A extends ReadonlyArray<unknown>
>(combiners: {
readonly [K in keyof A]: Combiner.Combiner<A[K]>
}): Combiner.Combiner<A>
Creates a Combiner for a tuple shape by providing a Combiner for each
position. When two tuples are combined, each element is merged using its
corresponding combiner.
When to use
Use when you need to merge two same-shape tuples by combining each position
independently, such as summing counters or concatenating strings.
Example (Combining tuple elements)
import { Number, String, Tuple } from "effect"
const C = Tuple.makeCombiner<readonly [number, string]>([
Number.ReducerSum,
String.ReducerConcat
])
const result = C.combine([1, "hello"], [2, " world"])
console.log(result) // [3, "hello world"]
makeCombiner(reducers: {
readonly [K in keyof A]: Reducer.Reducer<A[K]>
}
reducers).combine
const const initialValue: any[]initialValue = []
for (let let i: numberi = 0; let i: numberi < reducers: {
readonly [K in keyof A]: Reducer.Reducer<A[K]>
}
reducers.length; let i: numberi++) {
const initialValue: any[]initialValue.Array<any>.push(...items: any[]): numberAppends new elements to the end of an array, and returns the new length of the array.
push(reducers: {
readonly [K in keyof A]: Reducer.Reducer<A[K]>
}
reducers[let i: numberi].initialValue)
}
return import ReducerReducer.make(const combine: anycombine, const initialValue: any[]initialValue as unknown as function (type parameter) A in makeReducer<A extends ReadonlyArray<unknown>>(reducers: { readonly [K in keyof A]: Reducer.Reducer<A[K]>; }): Reducer.Reducer<A>A)
}