// ets_tracing: off import { failureOrCause } from "../Cause/index.js" import * as E from "../Either/index.js" import { chain_, foldCauseM_, halt } from "./core.js" import type { Effect } from "./effect.js" import { map_ } from "./map.js" /** * Returns an effect that effectfully "peeks" at the failure or success of * this effect. * * @ets_data_first tapBoth_ */ export function tapBoth( f: (e: E) => Effect, g: (a: A) => Effect, __trace?: string ) { return (self: Effect) => tapBoth_(self, f, g, __trace) } /** * Returns an effect that effectfully "peeks" at the failure or success of * this effect. */ export function tapBoth_( self: Effect, f: (e: E) => Effect, g: (a: A) => Effect, __trace?: string ) { return foldCauseM_( self, (c) => E.fold_( failureOrCause(c), (e) => chain_(f(e), () => halt(c)), (_) => halt(c) ), (a) => map_(g(a), () => a), __trace ) }