825 lines
24 KiB
JavaScript
825 lines
24 KiB
JavaScript
"use strict";
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (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.apSecondW = exports.apSecond = exports.apFirstW = exports.apFirst = exports.Apply = exports.Pointed = exports.flap = exports.Functor = exports.getAltReaderValidation = exports.getApplicativeReaderValidation = exports.getFilterable = exports.getCompactable = exports.URI = exports.throwError = exports.altW = exports.alt = exports.flatten = exports.flattenW = exports.chainW = exports.chain = exports.of = exports.apW = exports.ap = exports.mapLeft = exports.bimap = exports.map = exports.swap = exports.orLeft = exports.orElseFirstW = exports.orElseFirst = exports.orElseW = exports.orElse = exports.asksReaderEither = exports.asksReaderEitherW = exports.local = exports.toUnion = exports.getOrElseW = exports.getOrElse = exports.foldW = exports.matchEW = exports.fold = exports.matchE = exports.matchW = exports.match = exports.fromReader = exports.fromEither = exports.leftReader = exports.rightReader = exports.right = exports.left = void 0;
|
|
exports.getReaderValidation = exports.getSemigroup = exports.getApplyMonoid = exports.getApplySemigroup = exports.readerEither = exports.sequenceArray = exports.traverseArray = exports.traverseArrayWithIndex = exports.traverseReadonlyArrayWithIndex = exports.traverseReadonlyNonEmptyArrayWithIndex = exports.ApT = exports.apSW = exports.apS = exports.bindW = exports.bind = exports.let = exports.bindTo = exports.Do = exports.fromEitherK = exports.filterOrElseW = exports.filterOrElse = exports.fromPredicate = exports.chainFirstEitherKW = exports.chainFirstEitherK = exports.chainEitherKW = exports.chainEitherK = exports.chainOptionK = exports.fromOptionK = exports.fromOption = exports.FromEither = exports.MonadThrow = exports.chainFirstReaderKW = exports.chainFirstReaderK = exports.chainReaderKW = exports.chainReaderK = exports.fromReaderK = exports.asks = exports.ask = exports.FromReader = exports.Alt = exports.Bifunctor = exports.chainFirstW = exports.chainFirst = exports.Monad = exports.Chain = exports.Applicative = void 0;
|
|
var Applicative_1 = require("./Applicative");
|
|
var Apply_1 = require("./Apply");
|
|
var Chain_1 = require("./Chain");
|
|
var Compactable_1 = require("./Compactable");
|
|
var E = __importStar(require("./Either"));
|
|
var ET = __importStar(require("./EitherT"));
|
|
var Filterable_1 = require("./Filterable");
|
|
var FromEither_1 = require("./FromEither");
|
|
var FromReader_1 = require("./FromReader");
|
|
var function_1 = require("./function");
|
|
var Functor_1 = require("./Functor");
|
|
var _ = __importStar(require("./internal"));
|
|
var R = __importStar(require("./Reader"));
|
|
// -------------------------------------------------------------------------------------
|
|
// constructors
|
|
// -------------------------------------------------------------------------------------
|
|
/**
|
|
* @category constructors
|
|
* @since 2.0.0
|
|
*/
|
|
exports.left = ET.left(R.Pointed);
|
|
/**
|
|
* @category constructors
|
|
* @since 2.0.0
|
|
*/
|
|
exports.right = ET.right(R.Pointed);
|
|
/**
|
|
* @category constructors
|
|
* @since 2.0.0
|
|
*/
|
|
exports.rightReader =
|
|
/*#__PURE__*/ ET.rightF(R.Functor);
|
|
/**
|
|
* @category constructors
|
|
* @since 2.0.0
|
|
*/
|
|
exports.leftReader = ET.leftF(R.Functor);
|
|
// -------------------------------------------------------------------------------------
|
|
// conversions
|
|
// -------------------------------------------------------------------------------------
|
|
/**
|
|
* @category conversions
|
|
* @since 2.0.0
|
|
*/
|
|
exports.fromEither = R.of;
|
|
/**
|
|
* @category conversions
|
|
* @since 2.11.0
|
|
*/
|
|
exports.fromReader = exports.rightReader;
|
|
/**
|
|
* @category pattern matching
|
|
* @since 2.10.0
|
|
*/
|
|
exports.match = ET.match(R.Functor);
|
|
/**
|
|
* Less strict version of [`match`](#match).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the handler return types will be merged.
|
|
*
|
|
* @category pattern matching
|
|
* @since 2.10.0
|
|
*/
|
|
exports.matchW = exports.match;
|
|
/**
|
|
* The `E` suffix (short for **E**ffect) means that the handlers return an effect (`Reader`).
|
|
*
|
|
* @category pattern matching
|
|
* @since 2.10.0
|
|
*/
|
|
exports.matchE = ET.matchE(R.Monad);
|
|
/**
|
|
* Alias of [`matchE`](#matche).
|
|
*
|
|
* @category pattern matching
|
|
* @since 2.0.0
|
|
*/
|
|
exports.fold = exports.matchE;
|
|
/**
|
|
* Less strict version of [`matchE`](#matche).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the handler return types will be merged.
|
|
*
|
|
* @category pattern matching
|
|
* @since 2.10.0
|
|
*/
|
|
exports.matchEW = exports.matchE;
|
|
/**
|
|
* Alias of [`matchEW`](#matchew).
|
|
*
|
|
* @category pattern matching
|
|
* @since 2.10.0
|
|
*/
|
|
exports.foldW = exports.matchEW;
|
|
/**
|
|
* @category error handling
|
|
* @since 2.0.0
|
|
*/
|
|
exports.getOrElse =
|
|
/*#__PURE__*/ ET.getOrElse(R.Monad);
|
|
/**
|
|
* Less strict version of [`getOrElse`](#getorelse).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the handler return type will be merged.
|
|
*
|
|
* @category error handling
|
|
* @since 2.6.0
|
|
*/
|
|
exports.getOrElseW = exports.getOrElse;
|
|
/**
|
|
* @category conversions
|
|
* @since 2.10.0
|
|
*/
|
|
exports.toUnion = ET.toUnion(R.Functor);
|
|
// -------------------------------------------------------------------------------------
|
|
// combinators
|
|
// -------------------------------------------------------------------------------------
|
|
/**
|
|
* Changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s
|
|
* `contramap`).
|
|
*
|
|
* @since 2.0.0
|
|
*/
|
|
exports.local = R.local;
|
|
/**
|
|
* Less strict version of [`asksReaderEither`](#asksreadereither).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment types will be merged.
|
|
*
|
|
* @category constructors
|
|
* @since 2.11.0
|
|
*/
|
|
exports.asksReaderEitherW = R.asksReaderW;
|
|
/**
|
|
* Effectfully accesses the environment.
|
|
*
|
|
* @category constructors
|
|
* @since 2.11.0
|
|
*/
|
|
exports.asksReaderEither = exports.asksReaderEitherW;
|
|
/**
|
|
* @category error handling
|
|
* @since 2.0.0
|
|
*/
|
|
exports.orElse = ET.orElse(R.Monad);
|
|
/**
|
|
* Less strict version of [`orElse`](#orelse).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment types and the return types will be merged.
|
|
*
|
|
* @category error handling
|
|
* @since 2.10.0
|
|
*/
|
|
exports.orElseW = exports.orElse;
|
|
/**
|
|
* @category error handling
|
|
* @since 2.11.0
|
|
*/
|
|
exports.orElseFirst = ET.orElseFirst(R.Monad);
|
|
/**
|
|
* The `W` suffix (short for **W**idening) means that the environment types and the return types will be merged.
|
|
*
|
|
* @category error handling
|
|
* @since 2.11.0
|
|
*/
|
|
exports.orElseFirstW = exports.orElseFirst;
|
|
/**
|
|
* @category error handling
|
|
* @since 2.11.0
|
|
*/
|
|
exports.orLeft = ET.orLeft(R.Monad);
|
|
/**
|
|
* @since 2.0.0
|
|
*/
|
|
exports.swap = ET.swap(R.Functor);
|
|
/* istanbul ignore next */
|
|
var _map = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.map)(f)); };
|
|
/* istanbul ignore next */
|
|
var _bimap = function (fa, f, g) { return (0, function_1.pipe)(fa, (0, exports.bimap)(f, g)); };
|
|
/* istanbul ignore next */
|
|
var _mapLeft = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.mapLeft)(f)); };
|
|
/* istanbul ignore next */
|
|
var _ap = function (fab, fa) { return (0, function_1.pipe)(fab, (0, exports.ap)(fa)); };
|
|
/* istanbul ignore next */
|
|
var _chain = function (ma, f) { return (0, function_1.pipe)(ma, (0, exports.chain)(f)); };
|
|
/* istanbul ignore next */
|
|
var _alt = function (fa, that) { return (0, function_1.pipe)(fa, (0, exports.alt)(that)); };
|
|
/**
|
|
* `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
|
|
* use the type constructor `F` to represent some computational context.
|
|
*
|
|
* @category mapping
|
|
* @since 2.0.0
|
|
*/
|
|
exports.map =
|
|
/*#__PURE__*/ ET.map(R.Functor);
|
|
/**
|
|
* Map a pair of functions over the two last type arguments of the bifunctor.
|
|
*
|
|
* @category mapping
|
|
* @since 2.0.0
|
|
*/
|
|
exports.bimap = ET.bimap(R.Functor);
|
|
/**
|
|
* Map a function over the second type argument of a bifunctor.
|
|
*
|
|
* @category error handling
|
|
* @since 2.0.0
|
|
*/
|
|
exports.mapLeft =
|
|
/*#__PURE__*/ ET.mapLeft(R.Functor);
|
|
/**
|
|
* @since 2.0.0
|
|
*/
|
|
exports.ap = ET.ap(R.Apply);
|
|
/**
|
|
* Less strict version of [`ap`](#ap).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
|
|
*
|
|
* @since 2.8.0
|
|
*/
|
|
exports.apW = exports.ap;
|
|
/**
|
|
* @category constructors
|
|
* @since 2.8.5
|
|
*/
|
|
exports.of = exports.right;
|
|
/**
|
|
* Composes computations in sequence, using the return value of one computation to determine the next computation.
|
|
*
|
|
* @category sequencing
|
|
* @since 2.0.0
|
|
*/
|
|
exports.chain = ET.chain(R.Monad);
|
|
/**
|
|
* Less strict version of [`chain`](#chain).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
|
|
*
|
|
* @category sequencing
|
|
* @since 2.6.0
|
|
*/
|
|
exports.chainW = exports.chain;
|
|
/**
|
|
* Less strict version of [`flatten`](#flatten).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
|
|
*
|
|
* @category sequencing
|
|
* @since 2.11.0
|
|
*/
|
|
exports.flattenW = (0, exports.chainW)(function_1.identity);
|
|
/**
|
|
* @category sequencing
|
|
* @since 2.0.0
|
|
*/
|
|
exports.flatten = exports.flattenW;
|
|
/**
|
|
* Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
|
|
* types of kind `* -> *`.
|
|
*
|
|
* @category error handling
|
|
* @since 2.0.0
|
|
*/
|
|
exports.alt =
|
|
/*#__PURE__*/ ET.alt(R.Monad);
|
|
/**
|
|
* Less strict version of [`alt`](#alt).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment, the error and the return types will be merged.
|
|
*
|
|
* @category error handling
|
|
* @since 2.9.0
|
|
*/
|
|
exports.altW = exports.alt;
|
|
/**
|
|
* @since 2.7.0
|
|
*/
|
|
exports.throwError = exports.left;
|
|
/**
|
|
* @category type lambdas
|
|
* @since 2.0.0
|
|
*/
|
|
exports.URI = 'ReaderEither';
|
|
/**
|
|
* @category filtering
|
|
* @since 2.10.0
|
|
*/
|
|
var getCompactable = function (M) {
|
|
var C = E.getCompactable(M);
|
|
return {
|
|
URI: exports.URI,
|
|
_E: undefined,
|
|
compact: (0, Compactable_1.compact)(R.Functor, C),
|
|
separate: (0, Compactable_1.separate)(R.Functor, C, E.Functor)
|
|
};
|
|
};
|
|
exports.getCompactable = getCompactable;
|
|
/**
|
|
* @category filtering
|
|
* @since 2.10.0
|
|
*/
|
|
function getFilterable(M) {
|
|
var F = E.getFilterable(M);
|
|
var C = (0, exports.getCompactable)(M);
|
|
var filter = (0, Filterable_1.filter)(R.Functor, F);
|
|
var filterMap = (0, Filterable_1.filterMap)(R.Functor, F);
|
|
var partition = (0, Filterable_1.partition)(R.Functor, F);
|
|
var partitionMap = (0, Filterable_1.partitionMap)(R.Functor, F);
|
|
return {
|
|
URI: exports.URI,
|
|
_E: undefined,
|
|
map: _map,
|
|
compact: C.compact,
|
|
separate: C.separate,
|
|
filter: function (fa, predicate) { return (0, function_1.pipe)(fa, filter(predicate)); },
|
|
filterMap: function (fa, f) { return (0, function_1.pipe)(fa, filterMap(f)); },
|
|
partition: function (fa, predicate) { return (0, function_1.pipe)(fa, partition(predicate)); },
|
|
partitionMap: function (fa, f) { return (0, function_1.pipe)(fa, partitionMap(f)); }
|
|
};
|
|
}
|
|
exports.getFilterable = getFilterable;
|
|
/**
|
|
* The default [`Applicative`](#applicative) instance returns the first error, if you want to
|
|
* get all errors you need to provide a way to concatenate them via a `Semigroup`.
|
|
*
|
|
* See [`getApplicativeValidation`](./Either.ts.html#getapplicativevalidation).
|
|
*
|
|
* @category error handling
|
|
* @since 2.7.0
|
|
*/
|
|
function getApplicativeReaderValidation(S) {
|
|
var ap = (0, Apply_1.ap)(R.Apply, E.getApplicativeValidation(S));
|
|
return {
|
|
URI: exports.URI,
|
|
_E: undefined,
|
|
map: _map,
|
|
ap: function (fab, fa) { return (0, function_1.pipe)(fab, ap(fa)); },
|
|
of: exports.of
|
|
};
|
|
}
|
|
exports.getApplicativeReaderValidation = getApplicativeReaderValidation;
|
|
/**
|
|
* The default [`Alt`](#alt) instance returns the last error, if you want to
|
|
* get all errors you need to provide a way to concatenate them via a `Semigroup`.
|
|
*
|
|
* See [`getAltValidation`](./Either.ts.html#getaltvalidation).
|
|
*
|
|
* @category error handling
|
|
* @since 2.7.0
|
|
*/
|
|
function getAltReaderValidation(S) {
|
|
var alt = ET.altValidation(R.Monad, S);
|
|
return {
|
|
URI: exports.URI,
|
|
_E: undefined,
|
|
map: _map,
|
|
alt: function (fa, that) { return (0, function_1.pipe)(fa, alt(that)); }
|
|
};
|
|
}
|
|
exports.getAltReaderValidation = getAltReaderValidation;
|
|
/**
|
|
* @category instances
|
|
* @since 2.7.0
|
|
*/
|
|
exports.Functor = {
|
|
URI: exports.URI,
|
|
map: _map
|
|
};
|
|
/**
|
|
* @category mapping
|
|
* @since 2.10.0
|
|
*/
|
|
exports.flap = (0, Functor_1.flap)(exports.Functor);
|
|
/**
|
|
* @category instances
|
|
* @since 2.10.0
|
|
*/
|
|
exports.Pointed = {
|
|
URI: exports.URI,
|
|
of: exports.of
|
|
};
|
|
/**
|
|
* @category instances
|
|
* @since 2.10.0
|
|
*/
|
|
exports.Apply = {
|
|
URI: exports.URI,
|
|
map: _map,
|
|
ap: _ap
|
|
};
|
|
/**
|
|
* Combine two effectful actions, keeping only the result of the first.
|
|
*
|
|
* @since 2.0.0
|
|
*/
|
|
exports.apFirst = (0, Apply_1.apFirst)(exports.Apply);
|
|
/**
|
|
* Less strict version of [`apFirst`](#apfirst)
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
|
|
*
|
|
* @since 2.12.0
|
|
*/
|
|
exports.apFirstW = exports.apFirst;
|
|
/**
|
|
* Combine two effectful actions, keeping only the result of the second.
|
|
*
|
|
* @since 2.0.0
|
|
*/
|
|
exports.apSecond = (0, Apply_1.apSecond)(exports.Apply);
|
|
/**
|
|
* Less strict version of [`apSecond`](#apsecond)
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
|
|
*
|
|
* @since 2.12.0
|
|
*/
|
|
exports.apSecondW = exports.apSecond;
|
|
/**
|
|
* @category instances
|
|
* @since 2.7.0
|
|
*/
|
|
exports.Applicative = {
|
|
URI: exports.URI,
|
|
map: _map,
|
|
ap: _ap,
|
|
of: exports.of
|
|
};
|
|
/**
|
|
* @category instances
|
|
* @since 2.10.0
|
|
*/
|
|
exports.Chain = {
|
|
URI: exports.URI,
|
|
map: _map,
|
|
ap: _ap,
|
|
chain: _chain
|
|
};
|
|
/**
|
|
* @category instances
|
|
* @since 2.7.0
|
|
*/
|
|
exports.Monad = {
|
|
URI: exports.URI,
|
|
map: _map,
|
|
ap: _ap,
|
|
of: exports.of,
|
|
chain: _chain
|
|
};
|
|
/**
|
|
* Composes computations in sequence, using the return value of one computation to determine the next computation and
|
|
* keeping only the result of the first.
|
|
*
|
|
* @category sequencing
|
|
* @since 2.0.0
|
|
*/
|
|
exports.chainFirst = (0, Chain_1.chainFirst)(exports.Chain);
|
|
/**
|
|
* Less strict version of [`chainFirst`](#chainfirst)
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
|
|
*
|
|
* @category sequencing
|
|
* @since 2.8.0
|
|
*/
|
|
exports.chainFirstW = exports.chainFirst;
|
|
/**
|
|
* @category instances
|
|
* @since 2.7.0
|
|
*/
|
|
exports.Bifunctor = {
|
|
URI: exports.URI,
|
|
bimap: _bimap,
|
|
mapLeft: _mapLeft
|
|
};
|
|
/**
|
|
* @category instances
|
|
* @since 2.7.0
|
|
*/
|
|
exports.Alt = {
|
|
URI: exports.URI,
|
|
map: _map,
|
|
alt: _alt
|
|
};
|
|
/**
|
|
* @category instances
|
|
* @since 2.11.0
|
|
*/
|
|
exports.FromReader = {
|
|
URI: exports.URI,
|
|
fromReader: exports.fromReader
|
|
};
|
|
/**
|
|
* Reads the current context.
|
|
*
|
|
* @category constructors
|
|
* @since 2.0.0
|
|
*/
|
|
exports.ask = (0, FromReader_1.ask)(exports.FromReader);
|
|
/**
|
|
* Projects a value from the global context in a `ReaderEither`.
|
|
*
|
|
* @category constructors
|
|
* @since 2.0.0
|
|
*/
|
|
exports.asks = (0, FromReader_1.asks)(exports.FromReader);
|
|
/**
|
|
* @category lifting
|
|
* @since 2.11.0
|
|
*/
|
|
exports.fromReaderK = (0, FromReader_1.fromReaderK)(exports.FromReader);
|
|
/**
|
|
* @category sequencing
|
|
* @since 2.11.0
|
|
*/
|
|
exports.chainReaderK = (0, FromReader_1.chainReaderK)(exports.FromReader, exports.Chain);
|
|
/**
|
|
* Less strict version of [`chainReaderK`](#chainreaderk).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment types will be merged.
|
|
*
|
|
* @category sequencing
|
|
* @since 2.11.0
|
|
*/
|
|
exports.chainReaderKW = exports.chainReaderK;
|
|
/**
|
|
* @category sequencing
|
|
* @since 2.11.0
|
|
*/
|
|
exports.chainFirstReaderK = (0, FromReader_1.chainFirstReaderK)(exports.FromReader, exports.Chain);
|
|
/**
|
|
* Less strict version of [`chainReaderK`](#chainreaderk).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment types will be merged.
|
|
*
|
|
* @category sequencing
|
|
* @since 2.11.0
|
|
*/
|
|
exports.chainFirstReaderKW = exports.chainFirstReaderK;
|
|
/**
|
|
* @category instances
|
|
* @since 2.7.0
|
|
*/
|
|
exports.MonadThrow = {
|
|
URI: exports.URI,
|
|
map: _map,
|
|
ap: _ap,
|
|
of: exports.of,
|
|
chain: _chain,
|
|
throwError: exports.throwError
|
|
};
|
|
/**
|
|
* @category instances
|
|
* @since 2.10.0
|
|
*/
|
|
exports.FromEither = {
|
|
URI: exports.URI,
|
|
fromEither: exports.fromEither
|
|
};
|
|
/**
|
|
* @category conversions
|
|
* @since 2.0.0
|
|
*/
|
|
exports.fromOption =
|
|
/*#__PURE__*/ (0, FromEither_1.fromOption)(exports.FromEither);
|
|
/**
|
|
* @category lifting
|
|
* @since 2.10.0
|
|
*/
|
|
exports.fromOptionK = (0, FromEither_1.fromOptionK)(exports.FromEither);
|
|
/**
|
|
* @category sequencing
|
|
* @since 2.10.0
|
|
*/
|
|
exports.chainOptionK =
|
|
/*#__PURE__*/ (0, FromEither_1.chainOptionK)(exports.FromEither, exports.Chain);
|
|
/**
|
|
* @category sequencing
|
|
* @since 2.4.0
|
|
*/
|
|
exports.chainEitherK = (0, FromEither_1.chainEitherK)(exports.FromEither, exports.Chain);
|
|
/**
|
|
* Less strict version of [`chainEitherK`](#chaineitherk).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the error types will be merged.
|
|
*
|
|
* @category sequencing
|
|
* @since 2.6.1
|
|
*/
|
|
exports.chainEitherKW = exports.chainEitherK;
|
|
/**
|
|
* @category sequencing
|
|
* @since 2.12.0
|
|
*/
|
|
exports.chainFirstEitherK = (0, FromEither_1.chainFirstEitherK)(exports.FromEither, exports.Chain);
|
|
/**
|
|
* Less strict version of [`chainFirstEitherK`](#chainfirsteitherk).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment types will be merged.
|
|
*
|
|
* @category sequencing
|
|
* @since 2.12.0
|
|
*/
|
|
exports.chainFirstEitherKW = exports.chainFirstEitherK;
|
|
/**
|
|
* @category lifting
|
|
* @since 2.0.0
|
|
*/
|
|
exports.fromPredicate = (0, FromEither_1.fromPredicate)(exports.FromEither);
|
|
/**
|
|
* @category filtering
|
|
* @since 2.0.0
|
|
*/
|
|
exports.filterOrElse = (0, FromEither_1.filterOrElse)(exports.FromEither, exports.Chain);
|
|
/**
|
|
* Less strict version of [`filterOrElse`](#filterorelse).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the error types will be merged.
|
|
*
|
|
* @category filtering
|
|
* @since 2.9.0
|
|
*/
|
|
exports.filterOrElseW = exports.filterOrElse;
|
|
/**
|
|
* @category lifting
|
|
* @since 2.4.0
|
|
*/
|
|
exports.fromEitherK = (0, FromEither_1.fromEitherK)(exports.FromEither);
|
|
// -------------------------------------------------------------------------------------
|
|
// do notation
|
|
// -------------------------------------------------------------------------------------
|
|
/**
|
|
* @category do notation
|
|
* @since 2.9.0
|
|
*/
|
|
exports.Do = (0, exports.of)(_.emptyRecord);
|
|
/**
|
|
* @category do notation
|
|
* @since 2.8.0
|
|
*/
|
|
exports.bindTo = (0, Functor_1.bindTo)(exports.Functor);
|
|
var let_ = /*#__PURE__*/ (0, Functor_1.let)(exports.Functor);
|
|
exports.let = let_;
|
|
/**
|
|
* @category do notation
|
|
* @since 2.8.0
|
|
*/
|
|
exports.bind = (0, Chain_1.bind)(exports.Chain);
|
|
/**
|
|
* The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
|
|
*
|
|
* @category do notation
|
|
* @since 2.8.0
|
|
*/
|
|
exports.bindW = exports.bind;
|
|
/**
|
|
* @category do notation
|
|
* @since 2.8.0
|
|
*/
|
|
exports.apS = (0, Apply_1.apS)(exports.Apply);
|
|
/**
|
|
* Less strict version of [`apS`](#aps).
|
|
*
|
|
* The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged.
|
|
*
|
|
* @category do notation
|
|
* @since 2.8.0
|
|
*/
|
|
exports.apSW = exports.apS;
|
|
/**
|
|
* @since 2.11.0
|
|
*/
|
|
exports.ApT = (0, exports.of)(_.emptyReadonlyArray);
|
|
// -------------------------------------------------------------------------------------
|
|
// array utils
|
|
// -------------------------------------------------------------------------------------
|
|
/**
|
|
* Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`.
|
|
*
|
|
* @category traversing
|
|
* @since 2.11.0
|
|
*/
|
|
var traverseReadonlyNonEmptyArrayWithIndex = function (f) {
|
|
return (0, function_1.flow)(R.traverseReadonlyNonEmptyArrayWithIndex(f), R.map(E.traverseReadonlyNonEmptyArrayWithIndex(function_1.SK)));
|
|
};
|
|
exports.traverseReadonlyNonEmptyArrayWithIndex = traverseReadonlyNonEmptyArrayWithIndex;
|
|
/**
|
|
* Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.
|
|
*
|
|
* @category traversing
|
|
* @since 2.11.0
|
|
*/
|
|
var traverseReadonlyArrayWithIndex = function (f) {
|
|
var g = (0, exports.traverseReadonlyNonEmptyArrayWithIndex)(f);
|
|
return function (as) { return (_.isNonEmpty(as) ? g(as) : exports.ApT); };
|
|
};
|
|
exports.traverseReadonlyArrayWithIndex = traverseReadonlyArrayWithIndex;
|
|
/**
|
|
* Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.
|
|
*
|
|
* @category traversing
|
|
* @since 2.9.0
|
|
*/
|
|
exports.traverseArrayWithIndex = exports.traverseReadonlyArrayWithIndex;
|
|
/**
|
|
* Equivalent to `ReadonlyArray#traverse(Applicative)`.
|
|
*
|
|
* @category traversing
|
|
* @since 2.9.0
|
|
*/
|
|
var traverseArray = function (f) { return (0, exports.traverseReadonlyArrayWithIndex)(function (_, a) { return f(a); }); };
|
|
exports.traverseArray = traverseArray;
|
|
/**
|
|
* Equivalent to `ReadonlyArray#sequence(Applicative)`.
|
|
*
|
|
* @category traversing
|
|
* @since 2.9.0
|
|
*/
|
|
exports.sequenceArray = (0, exports.traverseArray)(function_1.identity);
|
|
// -------------------------------------------------------------------------------------
|
|
// deprecated
|
|
// -------------------------------------------------------------------------------------
|
|
/**
|
|
* This instance is deprecated, use small, specific instances instead.
|
|
* For example if a function needs a `Functor` instance, pass `RE.Functor` instead of `RE.readerEither`
|
|
* (where `R` is from `import R from 'fp-ts/ReaderEither'`)
|
|
*
|
|
* @category zone of death
|
|
* @since 2.0.0
|
|
* @deprecated
|
|
*/
|
|
exports.readerEither = {
|
|
URI: exports.URI,
|
|
bimap: _bimap,
|
|
mapLeft: _mapLeft,
|
|
map: _map,
|
|
of: exports.of,
|
|
ap: _ap,
|
|
chain: _chain,
|
|
alt: _alt,
|
|
throwError: exports.left
|
|
};
|
|
/**
|
|
* Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.
|
|
*
|
|
* @category zone of death
|
|
* @since 2.0.0
|
|
* @deprecated
|
|
*/
|
|
exports.getApplySemigroup =
|
|
/*#__PURE__*/ (0, Apply_1.getApplySemigroup)(exports.Apply);
|
|
/**
|
|
* Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.
|
|
*
|
|
* @category zone of death
|
|
* @since 2.0.0
|
|
* @deprecated
|
|
*/
|
|
exports.getApplyMonoid =
|
|
/*#__PURE__*/ (0, Applicative_1.getApplicativeMonoid)(exports.Applicative);
|
|
/**
|
|
* Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.
|
|
*
|
|
* @category zone of death
|
|
* @since 2.0.0
|
|
* @deprecated
|
|
*/
|
|
var getSemigroup = function (S) {
|
|
return (0, Apply_1.getApplySemigroup)(R.Apply)(E.getSemigroup(S));
|
|
};
|
|
exports.getSemigroup = getSemigroup;
|
|
/**
|
|
* Use [`getApplicativeReaderValidation`](#getapplicativereadervalidation) and [`getAltReaderValidation`](#getaltreadervalidation) instead.
|
|
*
|
|
* @category zone of death
|
|
* @since 2.3.0
|
|
* @deprecated
|
|
*/
|
|
function getReaderValidation(SE) {
|
|
var applicativeReaderValidation = getApplicativeReaderValidation(SE);
|
|
var altReaderValidation = getAltReaderValidation(SE);
|
|
return {
|
|
URI: exports.URI,
|
|
_E: undefined,
|
|
map: _map,
|
|
ap: applicativeReaderValidation.ap,
|
|
of: exports.of,
|
|
chain: _chain,
|
|
bimap: _bimap,
|
|
mapLeft: _mapLeft,
|
|
alt: altReaderValidation.alt,
|
|
throwError: exports.throwError
|
|
};
|
|
}
|
|
exports.getReaderValidation = getReaderValidation;
|