/** * Recovers from errors by accepting one effect to execute for the case of an * error, and one effect to execute for the case of success. * * This method has better performance than `either` since no intermediate * value is allocated and does not require subsequent calls to `chain` to * define the next effect. * * The error parameter of the returned `IO` may be chosen arbitrarily, since * it will depend on the `IO`s returned by the given continuations. * * @tsplus static effect/core/io/Effect.Aspects foldEffect * @tsplus pipeable effect/core/io/Effect foldEffect */ export function foldEffect( failure: (e: E) => Effect, success: (a: A) => Effect ) { return (self: Effect): Effect => self.foldCauseEffect( (cause) => cause.failureOrCause.fold(failure, Effect.failCause), success ) }