import * as tsplus_module_1 from "@effect/core/io/Effect/operations/failCauseNow";
import * as tsplus_module_2 from "@tsplus/stdlib/data/Either/definition";
import * as tsplus_module_3 from "@effect/core/io/Effect/operations/zipRight";
import * as tsplus_module_4 from "@effect/core/io/Cause/operations/failureOrCause";
import * as tsplus_module_5 from "@tsplus/stdlib/data/Either/fold";
import * as tsplus_module_6 from "@effect/core/io/Effect/operations/as";
import * as tsplus_module_7 from "@effect/core/io/Effect/operations/foldCauseEffect";
/**
 * Returns an effect that effectfully "peeks" at the result of this effect.
 *
 * @tsplus fluent ets/Effect tapEither
 */

export function tapEither_(self, f, __tsplusTrace) {
  return tsplus_module_7.foldCauseEffect_(self, cause => tsplus_module_5.fold_(tsplus_module_4.failureOrCause(cause), e => tsplus_module_3.zipRight_(f(tsplus_module_2.left(e)), () => tsplus_module_1.failCauseNow(cause, __tsplusTrace), __tsplusTrace), () => tsplus_module_1.failCauseNow(cause, __tsplusTrace)), a => tsplus_module_6.as_(f(tsplus_module_2.right(a)), () => a, __tsplusTrace), __tsplusTrace);
}
/**
 * Returns an effect that effectfully "peeks" at the result of this effect.
 *
 * @tsplus static ets/Effect/Aspects tapEither
 */

export const tapEither = (f, __tsplusTrace) => self => tapEither_(self, f, __tsplusTrace);
//# sourceMappingURL=tapEither.mjs.map