@matechs/effect
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -5,3 +5,3 @@ import * as F from "fluture"; | ||
import { Monad3E } from "./overload"; | ||
import { Cancel, ConcurrentFutureInstance } from "fluture"; | ||
import { Cancel } from "fluture"; | ||
import { MonadThrow3 } from "fp-ts/lib/MonadThrow"; | ||
@@ -12,13 +12,9 @@ import { Bifunctor3 } from "fp-ts/lib/Bifunctor"; | ||
export declare const URI = "matechs/Effect"; | ||
export declare const URIC = "matechs/ConcurrentEffect"; | ||
export declare type URI = typeof URI; | ||
export declare type URIC = typeof URIC; | ||
export declare type NoEnv = unknown; | ||
export declare type NoErr = never; | ||
export declare type Effect<R, E, A> = (r: R) => F.FutureInstance<E, A>; | ||
export declare type ConcurrentEffect<R, E, A> = (r: R) => ConcurrentFutureInstance<E, A>; | ||
declare module "fp-ts/lib/HKT" { | ||
interface URItoKind3<R, E, A> { | ||
[URI]: Effect<R, E, A>; | ||
[URIC]: ConcurrentEffect<R, E, A>; | ||
} | ||
@@ -28,3 +24,3 @@ } | ||
export declare const effectMonad: EffectMonad<URI>; | ||
export declare const concurrentEffectMonad: EffectMonad<URIC>; | ||
export declare const concurrentEffectMonad: EffectMonad<URI>; | ||
export declare const ap: <R, E, A, R2, E2>(fa: Effect<R, E, A>) => <B>(fab: Effect<R2, E2, (a: A) => B>) => Effect<R & R2, E | E2, B>, apFirst: <R, E, B>(fb: Effect<R, E, B>) => <A, R2, E2>(fa: Effect<R2, E2, A>) => Effect<R & R2, E | E2, A>, apSecond: <R, E, B>(fb: Effect<R, E, B>) => <A, R2, E2>(fa: Effect<R2, E2, A>) => Effect<R & R2, E | E2, B>, chain: <R, E, A, B>(f: (a: A) => Effect<R, E, B>) => <R2, E2>(ma: Effect<R2, E2, A>) => Effect<R & R2, E | E2, B>, chainFirst: <R, E, A, B>(f: (a: A) => Effect<R, E, B>) => <R2, E2>(ma: Effect<R2, E2, A>) => Effect<R & R2, E | E2, A>, flatten: <R, E, R2, E2, A>(mma: Effect<R, E, Effect<R2, E2, A>>) => Effect<R & R2, E | E2, A>, map: <A, B>(f: (a: A) => B) => <R, E>(fa: Effect<R, E, A>) => Effect<R, E, B>, bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => <R>(fa: Effect<R, E, A>) => Effect<R, G, B>, filterOrElse: { | ||
@@ -36,3 +32,4 @@ <E, A, B extends A>(refinement: import("fp-ts/lib/function").Refinement<A, B>, onFalse: (a: A) => E): <R>(ma: Effect<R, E, A>) => Effect<R, E, B>; | ||
<E_1, A_1>(predicate: import("fp-ts/lib/function").Predicate<A_1>, onFalse: (a: A_1) => E_1): <R>(a: A_1) => Effect<R, E_1, A_1>; | ||
}, mapLeft: <E, G>(f: (e: E) => G) => <R, A>(fa: Effect<R, E, A>) => Effect<R, G, A>, pipeablePar: import("./overload").PipeableChain3E<"matechs/ConcurrentEffect"> & import("fp-ts/lib/pipeable").PipeableBifunctor3<"matechs/ConcurrentEffect"> & import("fp-ts/lib/pipeable").PipeableMonadThrow3<"matechs/ConcurrentEffect">; | ||
}, mapLeft: <E, G>(f: (e: E) => G) => <R, A>(fa: Effect<R, E, A>) => Effect<R, G, A>; | ||
export declare const parAp: <R, E, A, R2, E2>(fa: Effect<R, E, A>) => <B>(fab: Effect<R2, E2, (a: A) => B>) => Effect<R & R2, E | E2, B>, parApFirst: <R, E, B>(fb: Effect<R, E, B>) => <A, R2, E2>(fa: Effect<R2, E2, A>) => Effect<R & R2, E | E2, A>, parApSecond: <R, E, B>(fb: Effect<R, E, B>) => <A, R2, E2>(fa: Effect<R2, E2, A>) => Effect<R & R2, E | E2, B>; | ||
export declare function error(message: string): Error; | ||
@@ -55,4 +52,2 @@ export declare function fromFuture<E, A>(f: F.FutureInstance<E, A>): Effect<NoEnv, E, A>; | ||
export declare function access<R, A>(f: (r: R) => A): Effect<R, NoErr, A>; | ||
export declare function par<R, E, A>(ma: Effect<R, E, A>): ConcurrentEffect<R, E, A>; | ||
export declare function seq<R, E, A>(ma: ConcurrentEffect<R, E, A>): Effect<R, E, A>; | ||
export declare function sequenceP<R, E, A>(n: number, ops: Array<Effect<R, E, A>>): Effect<R, E, Array<A>>; | ||
@@ -59,0 +54,0 @@ export declare function run<E, A>(ma: Effect<NoEnv, E, A>): () => Promise<Ei.Either<E, A>>; |
@@ -20,3 +20,3 @@ "use strict"; | ||
}; | ||
var _a; | ||
var _a, _b; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -28,6 +28,4 @@ var F = __importStar(require("fluture")); | ||
var pipeable_1 = require("fp-ts/lib/pipeable"); | ||
var fluture_1 = require("fluture"); | ||
var Option_1 = require("fp-ts/lib/Option"); | ||
exports.URI = "matechs/Effect"; | ||
exports.URIC = "matechs/ConcurrentEffect"; | ||
exports.effectMonad = { | ||
@@ -45,15 +43,5 @@ URI: exports.URI, | ||
}; | ||
exports.concurrentEffectMonad = { | ||
URI: exports.URIC, | ||
of: function (a) { return function (_) { return fluture_1.Par(F.resolve(a)); }; }, | ||
map: function (fa, f) { return function (r) { return fluture_1.Par(F.map(f)(fa(r).sequential)); }; }, | ||
ap: function (fab, fa) { return function (r) { return F.ap(fa(r))(fab(r)); }; }, | ||
chain: function (fa, f) { return function (r) { | ||
return fluture_1.Par(F.chain(function (x) { return f(x)(r).sequential; })(fa(r).sequential)); | ||
}; }, | ||
throwError: function (e) { return function (_) { return fluture_1.Par(F.reject(e)); }; }, | ||
bimap: function (fea, f, g) { return function (r) { return fluture_1.Par(F.bimap(f)(g)(fea(r).sequential)); }; }, | ||
mapLeft: function (fea, f) { return function (r) { return fluture_1.Par(F.mapRej(f)(fea(r).sequential)); }; } | ||
}; | ||
exports.ap = (_a = __assign(__assign({}, pipeable_1.pipeable(exports.effectMonad)), { pipeablePar: pipeable_1.pipeable(exports.concurrentEffectMonad) }), _a.ap), exports.apFirst = _a.apFirst, exports.apSecond = _a.apSecond, exports.chain = _a.chain, exports.chainFirst = _a.chainFirst, exports.flatten = _a.flatten, exports.map = _a.map, exports.bimap = _a.bimap, exports.filterOrElse = _a.filterOrElse, exports.fromEither = _a.fromEither, exports.fromOption = _a.fromOption, exports.fromPredicate = _a.fromPredicate, exports.mapLeft = _a.mapLeft, exports.pipeablePar = _a.pipeablePar; | ||
exports.concurrentEffectMonad = __assign(__assign({}, exports.effectMonad), { ap: function (fab, fa) { return function (r) { return F.ap(fa(r))(fab(r)); }; } }); | ||
exports.ap = (_a = pipeable_1.pipeable(exports.effectMonad), _a.ap), exports.apFirst = _a.apFirst, exports.apSecond = _a.apSecond, exports.chain = _a.chain, exports.chainFirst = _a.chainFirst, exports.flatten = _a.flatten, exports.map = _a.map, exports.bimap = _a.bimap, exports.filterOrElse = _a.filterOrElse, exports.fromEither = _a.fromEither, exports.fromOption = _a.fromOption, exports.fromPredicate = _a.fromPredicate, exports.mapLeft = _a.mapLeft; | ||
exports.parAp = (_b = pipeable_1.pipeable(exports.concurrentEffectMonad), _b.ap), exports.parApFirst = _b.apFirst, exports.parApSecond = _b.apSecond; | ||
/* utils */ | ||
@@ -132,11 +120,2 @@ function error(message) { | ||
exports.access = access; | ||
/* convert par/seq */ | ||
function par(ma) { | ||
return function (r) { return fluture_1.Par(ma(r)); }; | ||
} | ||
exports.par = par; | ||
function seq(ma) { | ||
return function (r) { return ma(r).sequential; }; | ||
} | ||
exports.seq = seq; | ||
/* parallel */ | ||
@@ -143,0 +122,0 @@ function sequenceP(n, ops) { |
{ | ||
"name": "@matechs/effect", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"license": "MIT", | ||
@@ -37,3 +37,3 @@ "private": false, | ||
}, | ||
"gitHead": "4b80f685b48438b3bc765d99b342b395f9c50367" | ||
"gitHead": "c89bbb7b17debb0479c5b861d6e0794a7b78f99a" | ||
} |
Sorry, the diff of this file is not supported yet
31786
298