Package: effect
Module: Option
Creates a Reducer for Option<A> that prioritizes the first non-None
value and combines values when both are Some.
When to use
Use to build an Option reducer that falls back to the first available value
when either side may be absent.
Details
None + None → NoneSome(a) + None → Some(a)None + Some(b) → Some(b)Some(a) + Some(b) → Some(combine(a, b))NoneExample (Reducing with first-wins semantics)
import { Number, Option } from "effect"
const reducer = Option.makeReducer(Number.ReducerSum)
console.log(reducer.combineAll([Option.some(1), Option.none(), Option.some(2)]))
// Output: { _id: 'Option', _tag: 'Some', value: 3 }
See
makeReducerFailFast for fail-fast semanticsSignature
declare const makeReducer: <A>(combiner: Combiner.Combiner<A>) => Reducer.Reducer<Option<A>>
Since v4.0.0