|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655 |
- "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.fromTaskK = exports.FromTask = exports.chainFirstReaderIOK = exports.chainFirstReaderIOKW = exports.chainReaderIOK = exports.chainReaderIOKW = exports.fromReaderIOK = exports.chainFirstReaderKW = exports.chainFirstReaderK = exports.chainReaderKW = exports.chainReaderK = exports.fromReaderK = exports.asks = exports.ask = exports.FromReader = exports.chainFirstIOK = exports.chainIOK = exports.fromIOK = exports.FromIO = exports.chainFirstW = exports.chainFirst = exports.MonadTask = exports.MonadIO = exports.Monad = exports.Chain = exports.ApplicativeSeq = exports.ApplySeq = exports.ApplicativePar = exports.apSecond = exports.apFirst = exports.ApplyPar = exports.Pointed = exports.flap = exports.Functor = exports.URI = exports.flatten = exports.flattenW = exports.chainW = exports.chain = exports.of = exports.apW = exports.ap = exports.map = exports.asksReaderTask = exports.asksReaderTaskW = exports.local = exports.fromReaderIO = exports.fromIO = exports.fromTask = exports.fromReader = void 0;
- exports.run = exports.getMonoid = exports.getSemigroup = exports.readerTaskSeq = exports.readerTask = exports.sequenceSeqArray = exports.traverseSeqArray = exports.traverseSeqArrayWithIndex = exports.sequenceArray = exports.traverseArray = exports.traverseArrayWithIndex = exports.traverseReadonlyArrayWithIndexSeq = exports.traverseReadonlyNonEmptyArrayWithIndexSeq = exports.traverseReadonlyArrayWithIndex = exports.traverseReadonlyNonEmptyArrayWithIndex = exports.ApT = exports.apSW = exports.apS = exports.bindW = exports.bind = exports.let = exports.bindTo = exports.Do = exports.chainFirstTaskK = exports.chainTaskK = void 0;
- /**
- * @since 2.3.0
- */
- var Applicative_1 = require("./Applicative");
- var Apply_1 = require("./Apply");
- var Chain_1 = require("./Chain");
- var FromIO_1 = require("./FromIO");
- var FromReader_1 = require("./FromReader");
- var FromTask_1 = require("./FromTask");
- var function_1 = require("./function");
- var Functor_1 = require("./Functor");
- var _ = __importStar(require("./internal"));
- var R = __importStar(require("./Reader"));
- var RT = __importStar(require("./ReaderT"));
- var T = __importStar(require("./Task"));
- // -------------------------------------------------------------------------------------
- // conversions
- // -------------------------------------------------------------------------------------
- /**
- * @category conversions
- * @since 2.3.0
- */
- exports.fromReader = RT.fromReader(T.Pointed);
- /**
- * @category conversions
- * @since 2.3.0
- */
- exports.fromTask = R.of;
- /**
- * @category conversions
- * @since 2.3.0
- */
- exports.fromIO = (0, function_1.flow)(T.fromIO, exports.fromTask);
- /**
- * @category conversions
- * @since 2.13.0
- */
- exports.fromReaderIO = R.map(T.fromIO);
- // -------------------------------------------------------------------------------------
- // combinators
- // -------------------------------------------------------------------------------------
- /**
- * Changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s
- * `contramap`).
- *
- * @since 2.3.0
- */
- exports.local = R.local;
- /**
- * Less strict version of [`asksReaderTask`](#asksreadertask).
- *
- * The `W` suffix (short for **W**idening) means that the environment types will be merged.
- *
- * @category constructors
- * @since 2.11.0
- */
- exports.asksReaderTaskW = R.asksReaderW;
- /**
- * Effectfully accesses the environment.
- *
- * @category constructors
- * @since 2.11.0
- */
- exports.asksReaderTask = exports.asksReaderTaskW;
- var _map = function (fa, f) { return (0, function_1.pipe)(fa, (0, exports.map)(f)); };
- var _apPar = function (fab, fa) { return (0, function_1.pipe)(fab, (0, exports.ap)(fa)); };
- var _apSeq = function (fab, fa) {
- return (0, function_1.pipe)(fab, (0, exports.chain)(function (f) { return (0, function_1.pipe)(fa, (0, exports.map)(f)); }));
- };
- var _chain = function (ma, f) { return (0, function_1.pipe)(ma, (0, exports.chain)(f)); };
- /**
- * `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.3.0
- */
- exports.map = RT.map(T.Functor);
- /**
- * @since 2.3.0
- */
- exports.ap =
- /*#__PURE__*/ RT.ap(T.ApplyPar);
- /**
- * Less strict version of [`ap`](#ap).
- *
- * The `W` suffix (short for **W**idening) means that the environment types will be merged.
- *
- * @since 2.8.0
- */
- exports.apW = exports.ap;
- /**
- * @category constructors
- * @since 2.3.0
- */
- exports.of = RT.of(T.Pointed);
- /**
- * Composes computations in sequence, using the return value of one computation to determine the next computation.
- *
- * @category sequencing
- * @since 2.3.0
- */
- exports.chain =
- /*#__PURE__*/ RT.chain(T.Monad);
- /**
- * Less strict version of [`chain`](#chain).
- *
- * The `W` suffix (short for **W**idening) means that the environment types will be merged.
- *
- * @category sequencing
- * @since 2.6.7
- */
- exports.chainW = exports.chain;
- /**
- * Less strict version of [`flatten`](#flatten).
- *
- * The `W` suffix (short for **W**idening) means that the environment types will be merged.
- *
- * @category sequencing
- * @since 2.11.0
- */
- exports.flattenW =
- /*#__PURE__*/ (0, exports.chainW)(function_1.identity);
- /**
- * @category sequencing
- * @since 2.3.0
- */
- exports.flatten = exports.flattenW;
- /**
- * @category type lambdas
- * @since 2.3.0
- */
- exports.URI = 'ReaderTask';
- /**
- * @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
- };
- /**
- * Runs computations in parallel.
- *
- * @category instances
- * @since 2.10.0
- */
- exports.ApplyPar = {
- URI: exports.URI,
- map: _map,
- ap: _apPar
- };
- /**
- * Combine two effectful actions, keeping only the result of the first.
- *
- * @since 2.3.0
- */
- exports.apFirst = (0, Apply_1.apFirst)(exports.ApplyPar);
- /**
- * Combine two effectful actions, keeping only the result of the second.
- *
- * @since 2.3.0
- */
- exports.apSecond = (0, Apply_1.apSecond)(exports.ApplyPar);
- /**
- * Runs computations in parallel.
- *
- * @category instances
- * @since 2.7.0
- */
- exports.ApplicativePar = {
- URI: exports.URI,
- map: _map,
- ap: _apPar,
- of: exports.of
- };
- /**
- * Runs computations sequentially.
- *
- * @category instances
- * @since 2.10.0
- */
- exports.ApplySeq = {
- URI: exports.URI,
- map: _map,
- ap: _apSeq
- };
- /**
- * Runs computations sequentially.
- *
- * @category instances
- * @since 2.7.0
- */
- exports.ApplicativeSeq = {
- URI: exports.URI,
- map: _map,
- ap: _apSeq,
- of: exports.of
- };
- /**
- * @category instances
- * @since 2.10.0
- */
- exports.Chain = {
- URI: exports.URI,
- map: _map,
- ap: _apPar,
- chain: _chain
- };
- /**
- * @category instances
- * @since 2.10.0
- */
- exports.Monad = {
- URI: exports.URI,
- map: _map,
- of: exports.of,
- ap: _apPar,
- chain: _chain
- };
- /**
- * @category instances
- * @since 2.10.0
- */
- exports.MonadIO = {
- URI: exports.URI,
- map: _map,
- of: exports.of,
- ap: _apPar,
- chain: _chain,
- fromIO: exports.fromIO
- };
- /**
- * @category instances
- * @since 2.10.0
- */
- exports.MonadTask = {
- URI: exports.URI,
- map: _map,
- of: exports.of,
- ap: _apPar,
- chain: _chain,
- fromIO: exports.fromIO,
- fromTask: exports.fromTask
- };
- /**
- * 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.3.0
- */
- exports.chainFirst =
- /*#__PURE__*/ (0, Chain_1.chainFirst)(exports.Chain);
- /**
- * Less strict version of [`chainFirst`](#chainfirst).
- *
- * The `W` suffix (short for **W**idening) means that the environment types will be merged.
- *
- * @category sequencing
- * @since 2.11.0
- */
- exports.chainFirstW = exports.chainFirst;
- /**
- * @category instances
- * @since 2.10.0
- */
- exports.FromIO = {
- URI: exports.URI,
- fromIO: exports.fromIO
- };
- /**
- * @category lifting
- * @since 2.4.0
- */
- exports.fromIOK = (0, FromIO_1.fromIOK)(exports.FromIO);
- /**
- * @category sequencing
- * @since 2.4.0
- */
- exports.chainIOK =
- /*#__PURE__*/ (0, FromIO_1.chainIOK)(exports.FromIO, exports.Chain);
- /**
- * @category sequencing
- * @since 2.10.0
- */
- exports.chainFirstIOK =
- /*#__PURE__*/ (0, FromIO_1.chainFirstIOK)(exports.FromIO, exports.Chain);
- /**
- * @category instances
- * @since 2.11.0
- */
- exports.FromReader = {
- URI: exports.URI,
- fromReader: exports.fromReader
- };
- /**
- * Reads the current context.
- *
- * @category constructors
- * @since 2.3.0
- */
- exports.ask = (0, FromReader_1.ask)(exports.FromReader);
- /**
- * Projects a value from the global context in a `ReaderTask`.
- *
- * @category constructors
- * @since 2.3.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 =
- /*#__PURE__*/ (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 =
- /*#__PURE__*/ (0, FromReader_1.chainFirstReaderK)(exports.FromReader, exports.Chain);
- /**
- * Less strict version of [`chainFirstReaderK`](#chainfirstreaderk).
- *
- * 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 lifting
- * @since 2.13.0
- */
- var fromReaderIOK = function (f) {
- return function () {
- var a = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- a[_i] = arguments[_i];
- }
- return (0, exports.fromReaderIO)(f.apply(void 0, a));
- };
- };
- exports.fromReaderIOK = fromReaderIOK;
- /**
- * Less strict version of [`chainReaderIOK`](#chainreaderiok).
- *
- * @category sequencing
- * @since 2.13.0
- */
- var chainReaderIOKW = function (f) { return (0, exports.chainW)((0, exports.fromReaderIOK)(f)); };
- exports.chainReaderIOKW = chainReaderIOKW;
- /**
- * @category sequencing
- * @since 2.13.0
- */
- exports.chainReaderIOK = exports.chainReaderIOKW;
- /**
- * Less strict version of [`chainFirstReaderIOK`](#chainfirstreaderiok).
- *
- * @category sequencing
- * @since 2.13.0
- */
- var chainFirstReaderIOKW = function (f) { return (0, exports.chainFirstW)((0, exports.fromReaderIOK)(f)); };
- exports.chainFirstReaderIOKW = chainFirstReaderIOKW;
- /**
- * @category sequencing
- * @since 2.13.0
- */
- exports.chainFirstReaderIOK = exports.chainFirstReaderIOKW;
- /**
- * @category instances
- * @since 2.10.0
- */
- exports.FromTask = {
- URI: exports.URI,
- fromIO: exports.fromIO,
- fromTask: exports.fromTask
- };
- /**
- * @category lifting
- * @since 2.4.0
- */
- exports.fromTaskK = (0, FromTask_1.fromTaskK)(exports.FromTask);
- /**
- * @category sequencing
- * @since 2.4.0
- */
- exports.chainTaskK =
- /*#__PURE__*/ (0, FromTask_1.chainTaskK)(exports.FromTask, exports.Chain);
- /**
- * @category sequencing
- * @since 2.10.0
- */
- exports.chainFirstTaskK =
- /*#__PURE__*/ (0, FromTask_1.chainFirstTaskK)(exports.FromTask, exports.Chain);
- // -------------------------------------------------------------------------------------
- // 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 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.ApplyPar);
- /**
- * Less strict version of [`apS`](#aps).
- *
- * The `W` suffix (short for **W**idening) means that the environment 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(T.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 `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.
- *
- * @category traversing
- * @since 2.11.0
- */
- var traverseReadonlyNonEmptyArrayWithIndexSeq = function (f) {
- return (0, function_1.flow)(R.traverseReadonlyNonEmptyArrayWithIndex(f), R.map(T.traverseReadonlyNonEmptyArrayWithIndexSeq(function_1.SK)));
- };
- exports.traverseReadonlyNonEmptyArrayWithIndexSeq = traverseReadonlyNonEmptyArrayWithIndexSeq;
- /**
- * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.
- *
- * @category traversing
- * @since 2.11.0
- */
- var traverseReadonlyArrayWithIndexSeq = function (f) {
- var g = (0, exports.traverseReadonlyNonEmptyArrayWithIndexSeq)(f);
- return function (as) { return (_.isNonEmpty(as) ? g(as) : exports.ApT); };
- };
- exports.traverseReadonlyArrayWithIndexSeq = traverseReadonlyArrayWithIndexSeq;
- /**
- * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.
- *
- * @category traversing
- * @since 2.9.0
- */
- exports.traverseArrayWithIndex = exports.traverseReadonlyArrayWithIndex;
- /**
- * Equivalent to `ReadonlyArray#traverseWithIndex(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 =
- /*#__PURE__*/ (0, exports.traverseArray)(function_1.identity);
- /**
- * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.
- *
- * @category traversing
- * @since 2.10.0
- */
- exports.traverseSeqArrayWithIndex = exports.traverseReadonlyArrayWithIndexSeq;
- /**
- * Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.
- *
- * @category traversing
- * @since 2.10.0
- */
- var traverseSeqArray = function (f) { return (0, exports.traverseReadonlyArrayWithIndexSeq)(function (_, a) { return f(a); }); };
- exports.traverseSeqArray = traverseSeqArray;
- // -------------------------------------------------------------------------------------
- // deprecated
- // -------------------------------------------------------------------------------------
- /**
- * Use `traverseReadonlyArrayWithIndexSeq` instead.
- *
- * @category zone of death
- * @since 2.10.0
- * @deprecated
- */
- exports.sequenceSeqArray =
- /*#__PURE__*/ (0, exports.traverseSeqArray)(function_1.identity);
- /**
- * This instance is deprecated, use small, specific instances instead.
- * For example if a function needs a `Functor` instance, pass `RT.Functor` instead of `RT.readerTask`
- * (where `RT` is from `import RT from 'fp-ts/ReaderTask'`)
- *
- * @category zone of death
- * @since 2.3.0
- * @deprecated
- */
- exports.readerTask = {
- URI: exports.URI,
- map: _map,
- of: exports.of,
- ap: _apPar,
- chain: _chain,
- fromIO: exports.fromIO,
- fromTask: exports.fromTask
- };
- /**
- * This instance is deprecated, use small, specific instances instead.
- * For example if a function needs a `Functor` instance, pass `RT.Functor` instead of `RT.readerTaskSeq`
- * (where `RT` is from `import RT from 'fp-ts/ReaderTask'`)
- *
- * @category zone of death
- * @since 2.3.0
- * @deprecated
- */
- exports.readerTaskSeq = {
- URI: exports.URI,
- map: _map,
- of: exports.of,
- ap: _apSeq,
- chain: _chain,
- fromIO: exports.fromIO,
- fromTask: exports.fromTask
- };
- /**
- * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead.
- *
- * @category zone of death
- * @since 2.3.0
- * @deprecated
- */
- exports.getSemigroup =
- /*#__PURE__*/ (0, Apply_1.getApplySemigroup)(exports.ApplySeq);
- /**
- * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead.
- *
- * @category zone of death
- * @since 2.3.0
- * @deprecated
- */
- exports.getMonoid =
- /*#__PURE__*/ (0, Applicative_1.getApplicativeMonoid)(exports.ApplicativeSeq);
- /**
- * @category zone of death
- * @since 2.4.0
- * @deprecated
- */
- /* istanbul ignore next */
- function run(ma, r) {
- return ma(r)();
- }
- exports.run = run;
|