Package: effect
Module: Tuple
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"]
See
makeCombiner – like makeReducer but without an initial valueSignature
declare const makeReducer: <A extends ReadonlyArray<unknown>>(reducers: { readonly [K in keyof A]: Reducer.Reducer<A[K]>; }) => Reducer.Reducer<A>
Since v4.0.0