<A>(combiner: Combiner.Combiner<A>): Reducer.Reducer<A | undefined>Creates a Reducer for UndefinedOr<A> that prioritizes the first non-undefined
value and combines values when both operands are present.
When to use
Use when you need to reduce values that may be undefined, keeping the
first defined value as a fallback and combining only when both operands are
defined.
Details
Combining undefined with undefined returns undefined. Combining a
defined value with undefined keeps the defined value, so the first defined
value wins when only one side is present. When both values are defined, they
are combined with combiner.combine. The reducer's initial value is
undefined.
export function function makeReducer<A>(
combiner: Combiner.Combiner<A>
): Reducer.Reducer<A | undefined>
Creates a Reducer for UndefinedOr<A> that prioritizes the first non-undefined
value and combines values when both operands are present.
When to use
Use when you need to reduce values that may be undefined, keeping the
first defined value as a fallback and combining only when both operands are
defined.
Details
Combining undefined with undefined returns undefined. Combining a
defined value with undefined keeps the defined value, so the first defined
value wins when only one side is present. When both values are defined, they
are combined with combiner.combine. The reducer's initial value is
undefined.
makeReducer<function (type parameter) A in makeReducer<A>(combiner: Combiner.Combiner<A>): Reducer.Reducer<A | undefined>A>(combiner: Combiner.Combiner<A>(parameter) combiner: {
combine: (self: A, that: A) => A;
}
combiner: import CombinerCombiner.type Combiner.Combiner = /*unresolved*/ anyCombiner<function (type parameter) A in makeReducer<A>(combiner: Combiner.Combiner<A>): Reducer.Reducer<A | undefined>A>): import ReducerReducer.type Reducer.Reducer = /*unresolved*/ anyReducer<function (type parameter) A in makeReducer<A>(combiner: Combiner.Combiner<A>): Reducer.Reducer<A | undefined>A | undefined> {
return import ReducerReducer.make((self: anyself, that: anythat) => {
if (self: anyself === var undefinedundefined) return that: anythat
if (that: anythat === var undefinedundefined) return self: anyself
return combiner: Combiner.Combiner<A>(parameter) combiner: {
combine: (self: A, that: A) => A;
}
combiner.combine(self: anyself, that: anythat)
}, var undefinedundefined as function (type parameter) A in makeReducer<A>(combiner: Combiner.Combiner<A>): Reducer.Reducer<A | undefined>A | undefined)
}