// ets_tracing: off import type * as C from "./_internal/cause.js" import * as T from "./_internal/effect.js" import * as Exit from "./core.js" /** * Folds over the value or cause. */ export function foldM( failed: (e: C.Cause) => T.Effect, succeed: (a: A) => T.Effect ) { return (exit: Exit.Exit): T.Effect => foldM_(exit, failed, succeed) } /** * Folds over the value or cause. */ export function foldM_( exit: Exit.Exit, failed: (e: C.Cause) => T.Effect, succeed: (a: A) => T.Effect ): T.Effect { switch (exit._tag) { case "Success": { return succeed(exit.value) } case "Failure": { return failed(exit.cause) } } } /** * Applies the function `f` to the successful result of the `Exit` and * returns the result in a new `Exit`. */ export function forEach(f: (a: A2) => T.Effect) { return (exit: Exit.Exit) => forEach_(exit, f) } /** * Applies the function `f` to the successful result of the `Exit` and * returns the result in a new `Exit`. */ export function forEach_( exit: Exit.Exit, f: (a: A2) => T.Effect ): T.Effect> { switch (exit._tag) { case "Failure": { return T.succeed(Exit.halt(exit.cause)) } case "Success": { return T.result(f(exit.value)) } } } export { Exit, succeed, Success, Failure, halt, ap, as, chain, collectAll, flatten, fold, interrupt, interrupted, map, mapErrorCause, zipWith, bimap, chain_, collectAllPar, die, exists, fail, fold_, fromEither, fromOption, getOrElse, mapError, map_, orElseFail, succeeded, toEither, unit, zip, zipLeft, zipPar, zipParLeft, zipParRight, zipRight, zipRight_, zipWith_ } from "./core.js"