// ets_tracing: off import { failureOrCause } from "../Cause/index.js" import * as E from "../Either/index.js" import * as Ex from "../Exit/index.js" import { chain_, foldCauseM_, halt, succeed } from "./core.js" import type { Effect } from "./effect.js" /** * Returns an effect that effectfully "peeks" at the result of this effect as an `Exit`. */ export function tapExit_( self: Effect, f: (exit: Ex.Exit) => Effect, __trace?: string ) { return foldCauseM_( self, (c) => E.fold_( failureOrCause(c), (e) => chain_(f(Ex.fail(e)), (_) => halt(c)), (c) => halt(c) ), (a) => chain_(f(Ex.succeed(a)), (_) => succeed(a)), __trace ) } /** * Returns an effect that effectfully "peeks" at the result of this effect as an `Exit`. * * @ets_data_first tapExit_ */ export function tapExit( f: (exit: Ex.Exit) => Effect, __trace?: string ) { return (self: Effect) => tapExit_(self, f, __trace) }