// ets_tracing: off import type { Either } from "../Either/index.js" import { pipe } from "../Function/index.js" import * as core from "./core.js" import type { Effect } from "./effect.js" import { either } from "./either.js" import { fromEither } from "./fromEither.js" /** * Returns an effect that effectfully "peeks" at the result of this effect as an `Either`. */ export function tapEither_( self: Effect, f: (exit: Either) => Effect, __trace?: string ): Effect { return pipe( either(self), core.chain((exit) => pipe( f(exit), core.chain(() => fromEither(() => exit)) ) ) ) } /** * Returns an effect that effectfully "peeks" at the result of this effect as an `Either`. * * @ets_data_first tapEither_ */ export function tapEither( f: (exit: Either) => Effect, __trace?: string ) { return (self: Effect) => tapEither_(self, f, __trace) }