init component
This commit is contained in:
871
node_modules/fp-ts/es6/TaskOption.js
generated
vendored
Normal file
871
node_modules/fp-ts/es6/TaskOption.js
generated
vendored
Normal file
@@ -0,0 +1,871 @@
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
import { apFirst as apFirst_, apS as apS_, apSecond as apSecond_ } from './Apply';
|
||||
import * as chainable from './Chain';
|
||||
import { compact as compact_, separate as separate_ } from './Compactable';
|
||||
import { filter as filter_, filterMap as filterMap_, partition as partition_, partitionMap as partitionMap_ } from './Filterable';
|
||||
import { chainEitherK as chainEitherK_, fromEitherK as fromEitherK_, tapEither as tapEither_ } from './FromEither';
|
||||
import { fromIOK as fromIOK_, tapIO as tapIO_ } from './FromIO';
|
||||
import { fromTaskK as fromTaskK_, tapTask as tapTask_ } from './FromTask';
|
||||
import { dual, flow, identity, pipe, SK } from './function';
|
||||
import { as as as_, asUnit as asUnit_, bindTo as bindTo_, flap as flap_, let as let__ } from './Functor';
|
||||
import * as _ from './internal';
|
||||
import * as O from './Option';
|
||||
import * as OT from './OptionT';
|
||||
import * as T from './Task';
|
||||
import { guard as guard_ } from './Zero';
|
||||
// -------------------------------------------------------------------------------------
|
||||
// constructors
|
||||
// -------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @category constructors
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var some = /*#__PURE__*/ OT.some(T.Pointed);
|
||||
/**
|
||||
* @category lifting
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var fromPredicate = /*#__PURE__*/ OT.fromPredicate(T.Pointed);
|
||||
// -------------------------------------------------------------------------------------
|
||||
// conversions
|
||||
// -------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @category conversions
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var fromOption = T.of;
|
||||
/**
|
||||
* @category conversions
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var fromEither = /*#__PURE__*/ OT.fromEither(T.Pointed);
|
||||
/**
|
||||
* @category conversions
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var fromIO = function (ma) { return fromTask(T.fromIO(ma)); };
|
||||
/**
|
||||
* @category conversions
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var fromTask = /*#__PURE__*/ OT.fromF(T.Functor);
|
||||
/**
|
||||
* @category conversions
|
||||
* @since 2.11.0
|
||||
*/
|
||||
export var fromTaskEither = /*#__PURE__*/ T.map(O.fromEither);
|
||||
/**
|
||||
* @category pattern matching
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var match =
|
||||
/*#__PURE__*/ OT.match(T.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
|
||||
*/
|
||||
export var matchW = match;
|
||||
/**
|
||||
* The `E` suffix (short for **E**ffect) means that the handlers return an effect (`Task`).
|
||||
*
|
||||
* @category pattern matching
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var matchE =
|
||||
/*#__PURE__*/ OT.matchE(T.Chain);
|
||||
/**
|
||||
* Alias of [`matchE`](#matche).
|
||||
*
|
||||
* @category pattern matching
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var fold = 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
|
||||
*/
|
||||
export var matchEW = matchE;
|
||||
/**
|
||||
* Alias of [`matchEW`](#matchew).
|
||||
*
|
||||
* @category pattern matching
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var foldW = matchEW;
|
||||
/**
|
||||
* @category error handling
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var getOrElse = /*#__PURE__*/ OT.getOrElse(T.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.10.0
|
||||
*/
|
||||
export var getOrElseW = getOrElse;
|
||||
/**
|
||||
* @category conversions
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var fromNullable = /*#__PURE__*/ OT.fromNullable(T.Pointed);
|
||||
/**
|
||||
* Transforms a `Promise` that may reject to a `Promise` that never rejects and returns an `Option` instead.
|
||||
*
|
||||
* See also [`tryCatchK`](#trycatchk).
|
||||
*
|
||||
* @category interop
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var tryCatch = function (f) {
|
||||
return function () { return __awaiter(void 0, void 0, void 0, function () {
|
||||
var reason_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [4 /*yield*/, f().then(_.some)];
|
||||
case 1: return [2 /*return*/, _a.sent()];
|
||||
case 2:
|
||||
reason_1 = _a.sent();
|
||||
return [2 /*return*/, _.none];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); };
|
||||
};
|
||||
/**
|
||||
* Converts a function returning a `Promise` to one returning a `TaskOption`.
|
||||
*
|
||||
* @category interop
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var tryCatchK = function (f) {
|
||||
return function () {
|
||||
var a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
a[_i] = arguments[_i];
|
||||
}
|
||||
return tryCatch(function () { return f.apply(void 0, a); });
|
||||
};
|
||||
};
|
||||
/**
|
||||
* @category lifting
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var fromNullableK = /*#__PURE__*/ OT.fromNullableK(T.Pointed);
|
||||
/**
|
||||
* @category sequencing
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var chainNullableK = /*#__PURE__*/ OT.chainNullableK(T.Monad);
|
||||
// -------------------------------------------------------------------------------------
|
||||
// combinators
|
||||
// -------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @category lifting
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var fromOptionK = /*#__PURE__*/ OT.fromOptionK(T.Pointed);
|
||||
/**
|
||||
* @category sequencing
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var chainOptionK =
|
||||
/*#__PURE__*/ OT.chainOptionK(T.Monad);
|
||||
/**
|
||||
* `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.10.0
|
||||
*/
|
||||
export var map = /*#__PURE__*/ OT.map(T.Functor);
|
||||
/**
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var ap = /*#__PURE__*/ OT.ap(T.ApplyPar);
|
||||
/**
|
||||
* @category constructors
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var of = some;
|
||||
/** @internal */
|
||||
var _FromIO = {
|
||||
fromIO: fromIO
|
||||
};
|
||||
/** @internal */
|
||||
var _FromTask = {
|
||||
fromTask: fromTask
|
||||
};
|
||||
/**
|
||||
* @category sequencing
|
||||
* @since 2.14.0
|
||||
*/
|
||||
export var flatMap = /*#__PURE__*/ dual(2, OT.flatMap(T.Monad));
|
||||
/** @internal */
|
||||
var _FlatMap = {
|
||||
flatMap: flatMap
|
||||
};
|
||||
/**
|
||||
* @category sequencing
|
||||
* @since 2.16.0
|
||||
*/
|
||||
export var flatMapIO = /*#__PURE__*/ _.flatMapIO(_FromIO, _FlatMap);
|
||||
/**
|
||||
* @category sequencing
|
||||
* @since 2.16.0
|
||||
*/
|
||||
export var flatMapTask = /*#__PURE__*/ _.flatMapTask(_FromTask, _FlatMap);
|
||||
/**
|
||||
* @category sequencing
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var flatten = /*#__PURE__*/ flatMap(identity);
|
||||
/**
|
||||
* @category error handling
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var alt = /*#__PURE__*/ OT.alt(T.Monad);
|
||||
/**
|
||||
* Less strict version of [`alt`](#alt).
|
||||
*
|
||||
* The `W` suffix (short for **W**idening) means that the return types will be merged.
|
||||
*
|
||||
* @category error handling
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var altW = alt;
|
||||
/**
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var zero = /*#__PURE__*/ OT.zero(T.Pointed);
|
||||
/**
|
||||
* @category constructors
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var none = /*#__PURE__*/ zero();
|
||||
/**
|
||||
* @category filtering
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var compact = /*#__PURE__*/ compact_(T.Functor, O.Compactable);
|
||||
/**
|
||||
* @category filtering
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var separate = /*#__PURE__*/ separate_(T.Functor, O.Compactable, O.Functor);
|
||||
/**
|
||||
* @category filtering
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var filter = /*#__PURE__*/ filter_(T.Functor, O.Filterable);
|
||||
/**
|
||||
* @category filtering
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var filterMap =
|
||||
/*#__PURE__*/ filterMap_(T.Functor, O.Filterable);
|
||||
/**
|
||||
* @category filtering
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var partition = /*#__PURE__*/ partition_(T.Functor, O.Filterable);
|
||||
/**
|
||||
* @category filtering
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var partitionMap = /*#__PURE__*/ partitionMap_(T.Functor, O.Filterable);
|
||||
// -------------------------------------------------------------------------------------
|
||||
// instances
|
||||
// -------------------------------------------------------------------------------------
|
||||
var _map = function (fa, f) { return pipe(fa, map(f)); };
|
||||
var _ap = function (fab, fa) { return pipe(fab, ap(fa)); };
|
||||
/* istanbul ignore next */
|
||||
var _alt = function (fa, that) { return pipe(fa, alt(that)); };
|
||||
/* istanbul ignore next */
|
||||
var _filter = function (fa, predicate) {
|
||||
return pipe(fa, filter(predicate));
|
||||
};
|
||||
/* istanbul ignore next */
|
||||
var _filterMap = function (fa, f) { return pipe(fa, filterMap(f)); };
|
||||
/* istanbul ignore next */
|
||||
var _partition = function (fa, predicate) {
|
||||
return pipe(fa, partition(predicate));
|
||||
};
|
||||
/* istanbul ignore next */
|
||||
var _partitionMap = function (fa, f) { return pipe(fa, partitionMap(f)); };
|
||||
/**
|
||||
* @category type lambdas
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var URI = 'TaskOption';
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var Functor = {
|
||||
URI: URI,
|
||||
map: _map
|
||||
};
|
||||
/**
|
||||
* Maps the `Some` value of this `TaskOption` to the specified constant value.
|
||||
*
|
||||
* @category mapping
|
||||
* @since 2.16.0
|
||||
*/
|
||||
export var as = dual(2, as_(Functor));
|
||||
/**
|
||||
* Maps the `Some` value of this `TaskOption` to the void constant value.
|
||||
*
|
||||
* @category mapping
|
||||
* @since 2.16.0
|
||||
*/
|
||||
export var asUnit = asUnit_(Functor);
|
||||
/**
|
||||
* @category mapping
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var flap = /*#__PURE__*/ flap_(Functor);
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var Pointed = {
|
||||
URI: URI,
|
||||
of: of
|
||||
};
|
||||
/**
|
||||
* Runs computations in parallel.
|
||||
*
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var ApplyPar = {
|
||||
URI: URI,
|
||||
map: _map,
|
||||
ap: _ap
|
||||
};
|
||||
/**
|
||||
* Combine two effectful actions, keeping only the result of the first.
|
||||
*
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var apFirst = /*#__PURE__*/ apFirst_(ApplyPar);
|
||||
/**
|
||||
* Combine two effectful actions, keeping only the result of the second.
|
||||
*
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var apSecond = /*#__PURE__*/ apSecond_(ApplyPar);
|
||||
/**
|
||||
* Runs computations in parallel.
|
||||
*
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var ApplicativePar = {
|
||||
URI: URI,
|
||||
map: _map,
|
||||
ap: _ap,
|
||||
of: of
|
||||
};
|
||||
var _apSeq = function (fab, fa) { return flatMap(fab, function (f) { return pipe(fa, map(f)); }); };
|
||||
/**
|
||||
* Runs computations sequentially.
|
||||
*
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var ApplySeq = {
|
||||
URI: URI,
|
||||
map: _map,
|
||||
ap: _apSeq
|
||||
};
|
||||
/**
|
||||
* Runs computations sequentially.
|
||||
*
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var ApplicativeSeq = {
|
||||
URI: URI,
|
||||
map: _map,
|
||||
ap: _apSeq,
|
||||
of: of
|
||||
};
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var Chain = {
|
||||
URI: URI,
|
||||
map: _map,
|
||||
ap: _ap,
|
||||
chain: flatMap
|
||||
};
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.11.0
|
||||
*/
|
||||
export var FromEither = {
|
||||
URI: URI,
|
||||
fromEither: fromEither
|
||||
};
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var FromIO = {
|
||||
URI: URI,
|
||||
fromIO: fromIO
|
||||
};
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var FromTask = {
|
||||
URI: URI,
|
||||
fromIO: fromIO,
|
||||
fromTask: 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 combinators
|
||||
* @since 2.15.0
|
||||
*/
|
||||
export var tap = /*#__PURE__*/ dual(2, chainable.tap(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.
|
||||
*
|
||||
* @example
|
||||
* import { pipe } from 'fp-ts/function'
|
||||
* import * as TO from 'fp-ts/TaskOption'
|
||||
* import * as O from 'fp-ts/Option'
|
||||
* import * as E from 'fp-ts/Either'
|
||||
*
|
||||
* const compute = (value: number) => pipe(
|
||||
* TO.of(value),
|
||||
* TO.tapEither((value) => value > 0 ? E.right('ok') : E.left('error')),
|
||||
* )
|
||||
*
|
||||
* async function test() {
|
||||
* assert.deepStrictEqual(await compute(1)(), O.of(1))
|
||||
* assert.deepStrictEqual(await compute(-1)(), O.none)
|
||||
* }
|
||||
*
|
||||
* test()
|
||||
*
|
||||
* @category combinators
|
||||
* @since 2.16.0
|
||||
*/
|
||||
export var tapEither = /*#__PURE__*/ dual(2, tapEither_(FromEither, 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.
|
||||
*
|
||||
* @example
|
||||
* import { pipe } from 'fp-ts/function'
|
||||
* import * as TO from 'fp-ts/TaskOption'
|
||||
* import * as O from 'fp-ts/Option'
|
||||
* import * as Console from 'fp-ts/Console'
|
||||
*
|
||||
*
|
||||
* // Will produce `Hello, fp-ts` to the stdout
|
||||
* const effectA = TO.tapIO(
|
||||
* TO.of(1),
|
||||
* (value) => Console.log(`Hello, ${value}`)
|
||||
* )
|
||||
*
|
||||
* // No output to the stdout
|
||||
* const effectB = pipe(
|
||||
* TO.none as TO.TaskOption<string>,
|
||||
* TO.tapIO((value) => Console.log(`Hello, ${value}`))
|
||||
* )
|
||||
*
|
||||
* async function test() {
|
||||
* assert.deepStrictEqual(await effectA(), O.of(1))
|
||||
* assert.deepStrictEqual(await effectB(), O.none)
|
||||
* }
|
||||
*
|
||||
* test()
|
||||
*
|
||||
* @category combinators
|
||||
* @since 2.16.0
|
||||
*/
|
||||
export var tapIO = /*#__PURE__*/ dual(2, tapIO_(FromIO, 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.
|
||||
*
|
||||
* @example
|
||||
* import * as TO from 'fp-ts/TaskOption'
|
||||
* import * as O from 'fp-ts/Option'
|
||||
* import * as T from 'fp-ts/Task'
|
||||
*
|
||||
* const effect = TO.tapIO(
|
||||
* TO.of(1),
|
||||
* (value) => T.of(value + 1)
|
||||
* )
|
||||
*
|
||||
* async function test() {
|
||||
* assert.deepStrictEqual(await effect(), O.of(1))
|
||||
* }
|
||||
*
|
||||
* test()
|
||||
*
|
||||
* @category combinators
|
||||
* @since 2.16.0
|
||||
*/
|
||||
export var tapTask = /*#__PURE__*/ dual(2, tapTask_(FromTask, Chain));
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var Alt = {
|
||||
URI: URI,
|
||||
map: _map,
|
||||
alt: _alt
|
||||
};
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.11.0
|
||||
*/
|
||||
export var Zero = {
|
||||
URI: URI,
|
||||
zero: zero
|
||||
};
|
||||
/**
|
||||
* @category do notation
|
||||
* @since 2.11.0
|
||||
*/
|
||||
export var guard = /*#__PURE__*/ guard_(Zero, Pointed);
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var Alternative = {
|
||||
URI: URI,
|
||||
map: _map,
|
||||
ap: _ap,
|
||||
of: of,
|
||||
alt: _alt,
|
||||
zero: zero
|
||||
};
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var Monad = {
|
||||
URI: URI,
|
||||
map: _map,
|
||||
ap: _ap,
|
||||
of: of,
|
||||
chain: flatMap
|
||||
};
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var MonadIO = {
|
||||
URI: URI,
|
||||
map: _map,
|
||||
ap: _ap,
|
||||
of: of,
|
||||
chain: flatMap,
|
||||
fromIO: fromIO
|
||||
};
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var MonadTask = {
|
||||
URI: URI,
|
||||
map: _map,
|
||||
ap: _ap,
|
||||
of: of,
|
||||
chain: flatMap,
|
||||
fromIO: fromIO,
|
||||
fromTask: fromTask
|
||||
};
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var Compactable = {
|
||||
URI: URI,
|
||||
compact: compact,
|
||||
separate: separate
|
||||
};
|
||||
/**
|
||||
* @category instances
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var Filterable = {
|
||||
URI: URI,
|
||||
map: _map,
|
||||
compact: compact,
|
||||
separate: separate,
|
||||
filter: _filter,
|
||||
filterMap: _filterMap,
|
||||
partition: _partition,
|
||||
partitionMap: _partitionMap
|
||||
};
|
||||
/**
|
||||
* @category lifting
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var fromIOK =
|
||||
/*#__PURE__*/ fromIOK_(FromIO);
|
||||
/**
|
||||
* Alias of `flatMapIO`.
|
||||
*
|
||||
* @category legacy
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var chainIOK = flatMapIO;
|
||||
/**
|
||||
* Alias of `tapIO`.
|
||||
*
|
||||
* @category legacy
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var chainFirstIOK = tapIO;
|
||||
/**
|
||||
* @category lifting
|
||||
* @since 2.12.0
|
||||
*/
|
||||
export var fromEitherK = /*#__PURE__*/ fromEitherK_(FromEither);
|
||||
/**
|
||||
* @category sequencing
|
||||
* @since 2.12.0
|
||||
*/
|
||||
export var chainEitherK =
|
||||
/*#__PURE__*/ chainEitherK_(FromEither, Chain);
|
||||
/**
|
||||
* Alias of `tapEither`.
|
||||
*
|
||||
* @category legacy
|
||||
* @since 2.12.0
|
||||
*/
|
||||
export var chainFirstEitherK = tapEither;
|
||||
/**
|
||||
* @category lifting
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var fromTaskK =
|
||||
/*#__PURE__*/ fromTaskK_(FromTask);
|
||||
/**
|
||||
* Alias of `flatMapTask`.
|
||||
*
|
||||
* @category legacy
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var chainTaskK = flatMapTask;
|
||||
/**
|
||||
* Alias of `tapTask`.
|
||||
*
|
||||
* @category legacy
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var chainFirstTaskK = tapTask;
|
||||
// -------------------------------------------------------------------------------------
|
||||
// do notation
|
||||
// -------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @category do notation
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var Do = /*#__PURE__*/ of(_.emptyRecord);
|
||||
/**
|
||||
* @category do notation
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var bindTo = /*#__PURE__*/ bindTo_(Functor);
|
||||
var let_ = /*#__PURE__*/ let__(Functor);
|
||||
export {
|
||||
/**
|
||||
* @category do notation
|
||||
* @since 2.13.0
|
||||
*/
|
||||
let_ as let };
|
||||
/**
|
||||
* @category do notation
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var bind = /*#__PURE__*/ chainable.bind(Chain);
|
||||
/**
|
||||
* @category do notation
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var apS = /*#__PURE__*/ apS_(ApplyPar);
|
||||
/**
|
||||
* @since 2.11.0
|
||||
*/
|
||||
export var ApT = /*#__PURE__*/ of(_.emptyReadonlyArray);
|
||||
// -------------------------------------------------------------------------------------
|
||||
// array utils
|
||||
// -------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`.
|
||||
*
|
||||
* @category traversing
|
||||
* @since 2.11.0
|
||||
*/
|
||||
export var traverseReadonlyNonEmptyArrayWithIndex = function (f) {
|
||||
return flow(T.traverseReadonlyNonEmptyArrayWithIndex(f), T.map(O.traverseReadonlyNonEmptyArrayWithIndex(SK)));
|
||||
};
|
||||
/**
|
||||
* Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`.
|
||||
*
|
||||
* @category traversing
|
||||
* @since 2.11.0
|
||||
*/
|
||||
export var traverseReadonlyArrayWithIndex = function (f) {
|
||||
var g = traverseReadonlyNonEmptyArrayWithIndex(f);
|
||||
return function (as) { return (_.isNonEmpty(as) ? g(as) : ApT); };
|
||||
};
|
||||
/**
|
||||
* Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`.
|
||||
*
|
||||
* @category traversing
|
||||
* @since 2.11.0
|
||||
*/
|
||||
export var traverseReadonlyNonEmptyArrayWithIndexSeq = function (f) {
|
||||
return function (as) {
|
||||
return function () {
|
||||
return _.tail(as).reduce(function (acc, a, i) {
|
||||
return acc.then(function (obs) {
|
||||
return _.isNone(obs)
|
||||
? acc
|
||||
: f(i + 1, a)().then(function (ob) {
|
||||
if (_.isNone(ob)) {
|
||||
return ob;
|
||||
}
|
||||
obs.value.push(ob.value);
|
||||
return obs;
|
||||
});
|
||||
});
|
||||
}, f(0, _.head(as))().then(O.map(_.singleton)));
|
||||
};
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.
|
||||
*
|
||||
* @category traversing
|
||||
* @since 2.11.0
|
||||
*/
|
||||
export var traverseReadonlyArrayWithIndexSeq = function (f) {
|
||||
var g = traverseReadonlyNonEmptyArrayWithIndexSeq(f);
|
||||
return function (as) { return (_.isNonEmpty(as) ? g(as) : ApT); };
|
||||
};
|
||||
/**
|
||||
* Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`.
|
||||
*
|
||||
* @category traversing
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var traverseArrayWithIndex = traverseReadonlyArrayWithIndex;
|
||||
/**
|
||||
* Equivalent to `ReadonlyArray#traverse(Applicative)`.
|
||||
*
|
||||
* @category traversing
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var traverseArray = function (f) { return traverseReadonlyArrayWithIndex(function (_, a) { return f(a); }); };
|
||||
/**
|
||||
* Equivalent to `ReadonlyArray#sequence(Applicative)`.
|
||||
*
|
||||
* @category traversing
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var sequenceArray =
|
||||
/*#__PURE__*/ traverseArray(identity);
|
||||
/**
|
||||
* Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`.
|
||||
*
|
||||
* @category traversing
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var traverseSeqArrayWithIndex = traverseReadonlyArrayWithIndexSeq;
|
||||
/**
|
||||
* Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`.
|
||||
*
|
||||
* @category traversing
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var traverseSeqArray = function (f) { return traverseReadonlyArrayWithIndexSeq(function (_, a) { return f(a); }); };
|
||||
/**
|
||||
* Equivalent to `ReadonlyArray#sequence(ApplicativeSeq)`.
|
||||
*
|
||||
* @category traversing
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var sequenceSeqArray =
|
||||
/*#__PURE__*/ traverseSeqArray(identity);
|
||||
// -------------------------------------------------------------------------------------
|
||||
// legacy
|
||||
// -------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Alias of `flatMap`.
|
||||
*
|
||||
* @category legacy
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var chain = flatMap;
|
||||
/**
|
||||
* Alias of `tap`.
|
||||
*
|
||||
* @category legacy
|
||||
* @since 2.10.0
|
||||
*/
|
||||
export var chainFirst = tap;
|
||||
Reference in New Issue
Block a user