/** * Simultaneously filters and flatMaps the value produced by this effect. * Continues on the effect returned from pf. * * @tsplus static effect/core/stm/STM.Aspects collectSTM * @tsplus pipeable effect/core/stm/STM collectSTM */ export function collectSTM(pf: (a: A) => STM>) { return (self: STM): STM => self.foldSTM( (_) => STM.fail(_), (a: A) => pf(a).flatMap((_) => _.isSome() ? STM.succeed(_.value) : STM.retry) ) }