// tracing: off
import { failureOrCause } from "../Cause"
import * as E from "../Either"
import { chain_, foldCauseM_, halt } from "./core"
import { map_ } from "./map"
/**
 * Returns an effect that effectfully "peeks" at the failure or success of
 * this effect.
 *
 * @dataFirst tapBoth_
 */

export function tapBoth(f, g, __trace) {
  return (self) => tapBoth_(self, f, g, __trace)
}
/**
 * Returns an effect that effectfully "peeks" at the failure or success of
 * this effect.
 */

export function tapBoth_(self, f, g, __trace) {
  return foldCauseM_(
    self,
    (c) =>
      E.fold_(
        failureOrCause(c),
        (e) => chain_(f(e), () => halt(c)),
        (_) => halt(c)
      ),
    (a) => map_(g(a), () => a),
    __trace
  )
}
//# sourceMappingURL=tapBoth.js.map
