"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.union = exports.unionFn = exports.run = exports.runEitherEnv = exports.runEither = exports.tryCatch = exports.succeedWith = exports.suspend = exports.zip_ = exports.zip = exports.zipWith_ = exports.zipWith = exports.orElseEither_ = exports.orElseEither = exports.either = exports.environment = exports.access = exports.accessM = exports.provideAll_ = exports.provideAll = exports.provide = exports.provideSome = exports.unit = exports.mapError_ = exports.mapError = exports.bimap_ = exports.bimap = exports.catchAll_ = exports.catchAll = exports.fold_ = exports.fold = exports.foldM = exports.foldM_ = exports.map = exports.map_ = exports.fail = exports.succeed = exports.tap_ = exports.tap = exports.chain_ = exports.chain = void 0;
const Function_1 = require("../Function");
const X = __importStar(require("../XPure"));
/**
 * Extends this computation with another computation that depends on the
 * result of this computation by running the first computation, using its
 * result to generate a second computation, and running that computation.
 */
exports.chain = X.chain;
/**
 * Extends this computation with another computation that depends on the
 * result of this computation by running the first computation, using its
 * result to generate a second computation, and running that computation.
 */
exports.chain_ = X.chain_;
/**
 * Returns a computation that effectfully "peeks" at the success of this one.
 */
exports.tap = X.tap;
/**
 * Returns a computation that effectfully "peeks" at the success of this one.
 */
exports.tap_ = X.tap_;
/**
 * Constructs a computation that always succeeds with the specified value,
 * passing the state through unchanged.
 */
const succeed = (a) => X.succeed(a);
exports.succeed = succeed;
/**
 * Constructs a computation that always succeeds with the specified value,
 * passing the state through unchanged.
 */
exports.fail = X.fail;
/**
 * Extends this computation with another computation that depends on the
 * result of this computation by running the first computation, using its
 * result to generate a second computation, and running that computation.
 */
exports.map_ = X.map_;
/**
 * Extends this computation with another computation that depends on the
 * result of this computation by running the first computation, using its
 * result to generate a second computation, and running that computation.
 */
exports.map = X.map;
/**
 * Recovers from errors by accepting one computation to execute for the case
 * of an error, and one computation to execute for the case of success.
 */
exports.foldM_ = X.foldM_;
/**
 * Recovers from errors by accepting one computation to execute for the case
 * of an error, and one computation to execute for the case of success.
 */
exports.foldM = X.foldM;
/**
 * Folds over the failed or successful results of this computation to yield
 * a computation that does not fail, but succeeds with the value of the left
 * or righr function passed to `fold`.
 */
exports.fold = X.fold;
/**
 * Folds over the failed or successful results of this computation to yield
 * a computation that does not fail, but succeeds with the value of the left
 * or righr function passed to `fold`.
 */
exports.fold_ = X.fold_;
/**
 * Recovers from all errors.
 */
exports.catchAll = X.catchAll;
/**
 * Recovers from all errors.
 */
exports.catchAll_ = X.catchAll_;
/**
 * Returns a computation whose error and success channels have been mapped
 * by the specified functions, `f` and `g`.
 */
exports.bimap = X.bimap;
/**
 * Returns a computation whose error and success channels have been mapped
 * by the specified functions, `f` and `g`.
 */
exports.bimap_ = X.bimap_;
/**
 * Transforms the error type of this computation with the specified
 * function.
 */
exports.mapError = X.mapError;
/**
 * Transforms the error type of this computation with the specified
 * function.
 */
exports.mapError_ = X.mapError_;
/**
 * Constructs a computation that always returns the `Unit` value, passing the
 * state through unchanged.
 */
exports.unit = (0, exports.succeed)(undefined);
/**
 * Transforms the initial state of this computation` with the specified
 * function.
 */
exports.provideSome = X.provideSome;
/**
 * Provides some of the environment required to run this effect,
 * leaving the remainder `R0` and combining it automatically using spread.
 */
exports.provide = X.provide;
/**
 * Provides this computation with its required environment.
 */
exports.provideAll = X.provideAll;
/**
 * Provides this computation with its required environment.
 */
exports.provideAll_ = X.provideAll_;
/**
 * Access the environment monadically
 */
exports.accessM = X.accessM;
/**
 * Access the environment with the function f
 */
exports.access = X.access;
/**
 * Access the environment
 */
const environment = () => X.environment();
exports.environment = environment;
/**
 * Returns a computation whose failure and success have been lifted into an
 * `Either`. The resulting computation cannot fail, because the failure case
 * has been exposed as part of the `Either` success case.
 */
exports.either = X.either;
/**
 * Executes this computation and returns its value, if it succeeds, but
 * otherwise executes the specified computation.
 */
exports.orElseEither = X.orElseEither;
/**
 * Executes this computation and returns its value, if it succeeds, but
 * otherwise executes the specified computation.
 */
exports.orElseEither_ = X.orElseEither_;
/**
 * Combines this computation with the specified computation, passing the
 * updated state from this computation to that computation and combining the
 * results of both using the specified function.
 */
exports.zipWith = X.zipWith;
/**
 * Combines this computation with the specified computation, passing the
 * updated state from this computation to that computation and combining the
 * results of both using the specified function.
 */
exports.zipWith_ = X.zipWith_;
/**
 * Combines this computation with the specified computation, passing the
 * updated state from this computation to that computation and combining the
 * results of both into a tuple.
 */
exports.zip = X.zip;
/**
 * Combines this computation with the specified computation, passing the
 * updated state from this computation to that computation and combining the
 * results of both into a tuple.
 */
exports.zip_ = X.zip_;
/**
 * Suspend a computation, useful in recursion
 */
exports.suspend = X.suspend;
/**
 * Lift a sync (non failable) computation
 */
exports.succeedWith = X.succeedWith;
/**
 * Lift a sync (non failable) computation
 */
exports.tryCatch = X.tryCatch;
/**
 * Runs this computation returning either an error of type E or a success of type A
 */
exports.runEither = X.runEither;
/**
 * Runs this computation returning either an error of type E or a success of type A
 */
const runEitherEnv = (r) => (x) => ((0, exports.runEither)((0, exports.provideAll)(r)(x)));
exports.runEitherEnv = runEitherEnv;
/**
 * Runs this non failable computation returning a success of type A
 */
exports.run = X.run;
/**
 * Compact the union produced by the result of f
 *
 * @ets_optimize identity
 */
function unionFn(_) {
    return _;
}
exports.unionFn = unionFn;
/**
 * Compact the union
 *
 * @ets_optimize identity
 */
function union(_) {
    return _;
}
exports.union = union;
//# sourceMappingURL=core.js.map