/** * Atomically reduce the non-empty array using a transactional binary * operator. * * @tsplus static effect/core/stm/TArray.Aspects reduceMaybeSTM * @tsplus pipeable effect/core/stm/TArray reduceMaybeSTM */ export function reduceMaybeSTM(f: (x: A, y: A) => STM) { return (self: TArray): STM> => self.reduceSTM( Maybe.empty(), (acc, a) => acc.fold(STM.some(a), (acc) => f(acc, a).map(Maybe.some)) ) }