@matechs/effect
Advanced tools
Comparing version 6.0.2 to 6.0.3
@@ -312,3 +312,15 @@ import { | ||
): F.FunctionN<[A], SyncE<E, B>>; | ||
export declare function liftOption<E>( | ||
onNone: () => E | ||
): <A, B>(f: F.FunctionN<[A], Op.Option<B>>) => F.FunctionN<[A], SyncE<E, B>>; | ||
/** | ||
* Combines T.chain and T.fromOption | ||
*/ | ||
export declare const flattenOption: <E>( | ||
onNone: () => E | ||
) => <S, R, E2, A>(eff: Effect<S, R, E2, Op.Option<A>>) => Effect<S, R, E | E2, A>; | ||
export declare const flattenEither: <S, R, E, E2, A>( | ||
eff: Effect<S, R, E, Ei.Either<E2, A>> | ||
) => Effect<S, R, E | E2, A>; | ||
/** | ||
* Map the value produced by an IO to the constant b | ||
@@ -938,11 +950,11 @@ * @param io | ||
) => Effect<S1 | S2, R & R2, E | E2, A>, | ||
fromEither: <S, R, E, A>(ma: Ei.Either<E, A>) => Effect<S, R, E, A>, | ||
fromOption: <E>(onNone: () => E) => <S, R, A>(ma: Op.Option<A>) => Effect<S, R, E, A>, | ||
fromEither: <E, A>(ma: Ei.Either<E, A>) => Effect<never, unknown, E, A>, | ||
fromOption: <E>(onNone: () => E) => <A>(ma: Op.Option<A>) => Effect<never, unknown, E, A>, | ||
fromPredicate: { | ||
<E, A, B extends A>(refinement: F.Refinement<A, B>, onFalse: (a: A) => E): <S, R>( | ||
<E, A, B extends A>(refinement: F.Refinement<A, B>, onFalse: (a: A) => E): ( | ||
a: A | ||
) => Effect<S, R, E, B>; | ||
<E_1, A_1>(predicate: F.Predicate<A_1>, onFalse: (a: A_1) => E_1): <S_1, R_1>( | ||
) => Effect<never, unknown, E, B>; | ||
<E_1, A_1>(predicate: F.Predicate<A_1>, onFalse: (a: A_1) => E_1): ( | ||
a: A_1 | ||
) => Effect<S_1, R_1, E_1, A_1>; | ||
) => Effect<never, unknown, E_1, A_1>; | ||
}, | ||
@@ -949,0 +961,0 @@ map: <A, B>(f: (a: A) => B) => <S, R, E>(fa: Effect<S, R, E, A>) => Effect<S, R, E, B>, |
@@ -266,3 +266,11 @@ import { either as Ei, function as F, option as Op, array as Ar, tree as TR, record as RE } from "fp-ts"; | ||
} | ||
export function liftOption(onNone) { | ||
return (f) => (a) => suspended(() => encaseOption(f(a), onNone)); | ||
} | ||
/** | ||
* Combines T.chain and T.fromOption | ||
*/ | ||
export const flattenOption = (onNone) => (eff) => chain_(eff, (x) => encaseOption(x, onNone)); | ||
export const flattenEither = (eff) => chain_(eff, encaseEither); | ||
/** | ||
* Map the value produced by an IO to the constant b | ||
@@ -269,0 +277,0 @@ * @param io |
@@ -536,2 +536,20 @@ import { Bifunctor4 } from "fp-ts/es6/Bifunctor"; | ||
} | ||
export interface PipeableMonadThrow4E<F extends MaURIS> { | ||
readonly fromOption: <E>(onNone: () => E) => <A>(ma: Option<A>) => Kind4<F, never, unknown, E, A>; | ||
readonly fromEither: <E, A>(ma: Either<E, A>) => Kind4<F, never, unknown, E, A>; | ||
readonly fromPredicate: { | ||
<E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): ( | ||
a: A | ||
) => Kind4<F, never, unknown, E, B>; | ||
<E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind4<F, never, unknown, E, A>; | ||
}; | ||
readonly filterOrElse: { | ||
<E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>( | ||
ma: Kind4<F, S, R, E, A> | ||
) => Kind4<F, S, R, E, B>; | ||
<E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>( | ||
ma: Kind4<F, S, R, E, A> | ||
) => Kind4<F, S, R, E, A>; | ||
}; | ||
} | ||
export interface PipeableAlt4E<F extends MaURIS> { | ||
@@ -575,3 +593,3 @@ readonly alt: <S1, R, E, A>( | ||
(I extends Semigroupoid4<F> ? PipeableSemigroupoid4<F> : {}) & | ||
(I extends MonadThrow4E<F> ? PipeableMonadThrow4<F> : {}); | ||
(I extends MonadThrow4E<F> ? PipeableMonadThrow4E<F> : {}); | ||
function pipeable<F extends MaURIS, I, E>( | ||
@@ -578,0 +596,0 @@ I: { |
@@ -312,3 +312,15 @@ import { | ||
): F.FunctionN<[A], SyncE<E, B>>; | ||
export declare function liftOption<E>( | ||
onNone: () => E | ||
): <A, B>(f: F.FunctionN<[A], Op.Option<B>>) => F.FunctionN<[A], SyncE<E, B>>; | ||
/** | ||
* Combines T.chain and T.fromOption | ||
*/ | ||
export declare const flattenOption: <E>( | ||
onNone: () => E | ||
) => <S, R, E2, A>(eff: Effect<S, R, E2, Op.Option<A>>) => Effect<S, R, E | E2, A>; | ||
export declare const flattenEither: <S, R, E, E2, A>( | ||
eff: Effect<S, R, E, Ei.Either<E2, A>> | ||
) => Effect<S, R, E | E2, A>; | ||
/** | ||
* Map the value produced by an IO to the constant b | ||
@@ -938,11 +950,11 @@ * @param io | ||
) => Effect<S1 | S2, R & R2, E | E2, A>, | ||
fromEither: <S, R, E, A>(ma: Ei.Either<E, A>) => Effect<S, R, E, A>, | ||
fromOption: <E>(onNone: () => E) => <S, R, A>(ma: Op.Option<A>) => Effect<S, R, E, A>, | ||
fromEither: <E, A>(ma: Ei.Either<E, A>) => Effect<never, unknown, E, A>, | ||
fromOption: <E>(onNone: () => E) => <A>(ma: Op.Option<A>) => Effect<never, unknown, E, A>, | ||
fromPredicate: { | ||
<E, A, B extends A>(refinement: F.Refinement<A, B>, onFalse: (a: A) => E): <S, R>( | ||
<E, A, B extends A>(refinement: F.Refinement<A, B>, onFalse: (a: A) => E): ( | ||
a: A | ||
) => Effect<S, R, E, B>; | ||
<E_1, A_1>(predicate: F.Predicate<A_1>, onFalse: (a: A_1) => E_1): <S_1, R_1>( | ||
) => Effect<never, unknown, E, B>; | ||
<E_1, A_1>(predicate: F.Predicate<A_1>, onFalse: (a: A_1) => E_1): ( | ||
a: A_1 | ||
) => Effect<S_1, R_1, E_1, A_1>; | ||
) => Effect<never, unknown, E_1, A_1>; | ||
}, | ||
@@ -949,0 +961,0 @@ map: <A, B>(f: (a: A) => B) => <S, R, E>(fa: Effect<S, R, E, A>) => Effect<S, R, E, B>, |
@@ -337,3 +337,12 @@ "use strict"; | ||
exports.liftEither = liftEither; | ||
function liftOption(onNone) { | ||
return function (f) { return function (a) { return suspended(function () { return encaseOption(f(a), onNone); }); }; }; | ||
} | ||
exports.liftOption = liftOption; | ||
/** | ||
* Combines T.chain and T.fromOption | ||
*/ | ||
exports.flattenOption = function (onNone) { return function (eff) { return chain_(eff, function (x) { return encaseOption(x, onNone); }); }; }; | ||
exports.flattenEither = function (eff) { return chain_(eff, encaseEither); }; | ||
/** | ||
* Map the value produced by an IO to the constant b | ||
@@ -340,0 +349,0 @@ * @param io |
@@ -536,2 +536,20 @@ import { Bifunctor4 } from "fp-ts/lib/Bifunctor"; | ||
} | ||
export interface PipeableMonadThrow4E<F extends MaURIS> { | ||
readonly fromOption: <E>(onNone: () => E) => <A>(ma: Option<A>) => Kind4<F, never, unknown, E, A>; | ||
readonly fromEither: <E, A>(ma: Either<E, A>) => Kind4<F, never, unknown, E, A>; | ||
readonly fromPredicate: { | ||
<E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): ( | ||
a: A | ||
) => Kind4<F, never, unknown, E, B>; | ||
<E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => Kind4<F, never, unknown, E, A>; | ||
}; | ||
readonly filterOrElse: { | ||
<E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): <S, R>( | ||
ma: Kind4<F, S, R, E, A> | ||
) => Kind4<F, S, R, E, B>; | ||
<E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <S, R>( | ||
ma: Kind4<F, S, R, E, A> | ||
) => Kind4<F, S, R, E, A>; | ||
}; | ||
} | ||
export interface PipeableAlt4E<F extends MaURIS> { | ||
@@ -575,3 +593,3 @@ readonly alt: <S1, R, E, A>( | ||
(I extends Semigroupoid4<F> ? PipeableSemigroupoid4<F> : {}) & | ||
(I extends MonadThrow4E<F> ? PipeableMonadThrow4<F> : {}); | ||
(I extends MonadThrow4E<F> ? PipeableMonadThrow4E<F> : {}); | ||
function pipeable<F extends MaURIS, I, E>( | ||
@@ -578,0 +596,0 @@ I: { |
{ | ||
"name": "@matechs/effect", | ||
"version": "6.0.2", | ||
"version": "6.0.3", | ||
"license": "MIT", | ||
@@ -43,3 +43,3 @@ "private": false, | ||
}, | ||
"gitHead": "dbf6875885d121e4e5aa9223db8b16a97a49e712" | ||
"gitHead": "ca780a034d8fd4e4ce1a64a618725e6730021dd7" | ||
} |
644467
18643