<A>(): Reducer.Reducer<Array<A>>Returns a Reducer that combines Array values by concatenation.
foldinggetReadonlyReducerConcat
Source effect/Array.ts:48583 lines
export function function makeReducerConcat<
A
>(): Reducer.Reducer<Array<A>>
Returns a Reducer that combines Array values by concatenation.
makeReducerConcat<function (type parameter) A in makeReducerConcat<A>(): Reducer.Reducer<Array<A>>A>(): import ReducerReducer.interface Reducer<A>Represents a strategy for reducing a collection of values of type A into
a single result.
When to use
Use when you need to fold/reduce a collection into a single value.
- You want a reusable reducing strategy that can be passed to library
functions like
Struct.makeReducer, Option.makeReducer, or
Record.makeReducerUnion.
- You need both the combining logic and a known starting value.
Details
Extends
Combiner.Combiner
with:
initialValue – the identity/neutral element for combine.
combineAll – folds an entire Iterable<A> from initialValue.
Many modules ship pre-built reducers:
Number.ReducerSum, Number.ReducerMultiply
String.ReducerConcat
Boolean.ReducerAnd, Boolean.ReducerOr
Example (String concatenation reducer)
import { Reducer } from "effect"
const Concat = Reducer.make<string>((a, b) => a + b, "")
console.log(Concat.combineAll(["hello", " ", "world"]))
// Output: "hello world"
Reducer<interface Array<T>Array<function (type parameter) A in makeReducerConcat<A>(): Reducer.Reducer<Array<A>>A>> {
return const reducer: Reducer.Reducer<any>const reducer: {
initialValue: A;
combineAll: (collection: Iterable<A>) => A;
combine: (self: A, that: A) => A;
}
reducer
}