Package: effect
Module: Option
Creates a Reducer for Option<A> by lifting an existing Reducer with
fail-fast semantics.
When to use
Use when you need to reduce Option values with fail-fast semantics, where
any None aborts the entire result instead of being skipped.
Details
Some(reducer.initialValue)SomeNone causes the result to become None immediatelyExample (Fail-fast reducing)
import { Number, Option } from "effect"
const reducer = Option.makeReducerFailFast(Number.ReducerSum)
console.log(reducer.combineAll([Option.some(1), Option.some(2)]))
// Output: { _id: 'Option', _tag: 'Some', value: 3 }
console.log(reducer.combineAll([Option.some(1), Option.none()]))
// Output: { _id: 'Option', _tag: 'None' }
See
makeCombinerFailFast for just the combinermakeReducer for non-fail-fast semanticsSignature
declare const makeReducerFailFast: <A>(reducer: Reducer.Reducer<A>) => Reducer.Reducer<Option<A>>
Since v4.0.0