UNPKG

@typed/fp

Version:

Data Structures and Resources for fp-ts

342 lines 10.9 kB
/** * DataEither is an ADT which allows you to represent all the states involved in loading a * piece of data asynchronously which might fail. * * @since 0.9.2 */ import * as Alt_ from 'fp-ts/Alt'; import * as Applicative_ from 'fp-ts/Applicative'; import * as Apply_ from 'fp-ts/Apply'; import * as Bifunctor_ from 'fp-ts/Bifunctor'; import * as Chain_ from 'fp-ts/Chain'; import * as ChainRec_ from 'fp-ts/ChainRec'; import * as Ei from 'fp-ts/Either'; import * as FEi from 'fp-ts/FromEither'; import * as Functor_ from 'fp-ts/Functor'; import * as Monad_ from 'fp-ts/Monad'; import * as Pointed_ from 'fp-ts/Pointed'; import * as Semigroup_ from 'fp-ts/Semigroup'; import * as D from './Data'; import { MonadRec2 } from './MonadRec'; /** * @since 0.9.2 * @category Model */ export declare type DataEither<E, A> = D.Data<Ei.Either<E, A>>; /** * @since 0.9.2 * @category Combinator */ export declare const alt: <E, A>(second: import("fp-ts/function").Lazy<D.Data<Ei.Either<E, A>>>) => (first: D.Data<Ei.Either<E, A>>) => D.Data<Ei.Either<E, A>>; /** * @since 0.9.2 * @category Typeclass Constructor */ export declare const altValidation: <A>(semigroup: Semigroup_.Semigroup<A>) => <A_1>(second: import("fp-ts/function").Lazy<D.Data<Ei.Either<A, A_1>>>) => (first: D.Data<Ei.Either<A, A_1>>) => D.Data<Ei.Either<A, A_1>>; /** * @since 0.9.2 * @category Combinator */ export declare const ap: <E, A>(fa: D.Data<Ei.Either<E, A>>) => <B>(fab: D.Data<Ei.Either<E, (a: A) => B>>) => D.Data<Ei.Either<E, B>>; /** * @since 0.9.2 * @category Combinator */ export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fea: D.Data<Ei.Either<E, A>>) => D.Data<Ei.Either<G, B>>; /** * @since 0.9.2 * @category Combinator */ export declare const bracket: <E, A, B>(acquire: D.Data<Ei.Either<E, A>>, use: (a: A) => D.Data<Ei.Either<E, B>>, release: (a: A, e: Ei.Either<E, B>) => D.Data<Ei.Either<E, void>>) => D.Data<Ei.Either<E, B>>; /** * @since 0.9.2 * @category Combinator */ export declare const chain: <A, E, B>(f: (a: A) => D.Data<Ei.Either<E, B>>) => (ma: D.Data<Ei.Either<E, A>>) => D.Data<Ei.Either<E, B>>; /** * @since 0.9.2 * @category Combinator */ export declare const getOrElse: <E, A>(onLeft: (e: E) => A) => (ma: D.Data<Ei.Either<E, A>>) => D.Data<A>; /** * @since 0.9.2 * @category Combinator */ export declare const getOrElseE: <E, A>(onLeft: (e: E) => D.Data<A>) => (ma: D.Data<Ei.Either<E, A>>) => D.Data<A>; /** * @since 0.9.2 * @category Constructor */ export declare const left: <E, A = never>(e: E) => D.Data<Ei.Either<E, A>>; /** * @since 0.9.2 * @category Constructor */ export declare const fromDataL: <E, A = never>(fe: D.Data<E>) => D.Data<Ei.Either<E, A>>; /** * @since 0.9.2 * @category Combinator */ export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: D.Data<Ei.Either<E, A>>) => D.Data<Ei.Either<E, B>>; /** * @since 0.9.2 * @category Combinator */ export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fea: D.Data<Ei.Either<E, A>>) => D.Data<Ei.Either<G, A>>; /** * @since 0.9.2 * @category Combinator */ export declare const match: <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: D.Data<Ei.Either<E, A>>) => D.Data<B>; /** * @since 0.9.2 * @category Combinator */ export declare const matchE: <E, B, A>(onLeft: (e: E) => D.Data<B>, onRight: (a: A) => D.Data<B>) => (ma: D.Data<Ei.Either<E, A>>) => D.Data<B>; /** * @since 0.9.2 * @category Combinator */ export declare const orElse: <E1, E2, A>(onLeft: (e: E1) => D.Data<Ei.Either<E2, A>>) => (ma: D.Data<Ei.Either<E1, A>>) => D.Data<Ei.Either<E2, A>>; /** * @since 0.9.2 * @category Combinator */ export declare const orElseFirst: <E, B>(onLeft: (e: E) => D.Data<Ei.Either<E, B>>) => <A>(ma: D.Data<Ei.Either<E, A>>) => D.Data<Ei.Either<E, A>>; /** * @since 0.9.2 * @category Combinator */ export declare const orLeft: <E1, E2>(onLeft: (e: E1) => D.Data<E2>) => <A>(fa: D.Data<Ei.Either<E1, A>>) => D.Data<Ei.Either<E2, A>>; /** * @since 0.9.2 * @category Combinator */ export declare const right: <A, E = never>(a: A) => D.Data<Ei.Either<E, A>>; /** * @since 0.9.2 * @category Constructor */ export declare const fromData: <A, E = never>(fa: D.Data<A>) => D.Data<Ei.Either<E, A>>; /** * @since 0.9.2 * @category Combinator */ export declare const swap: <E, A>(ma: D.Data<Ei.Either<E, A>>) => D.Data<Ei.Either<A, E>>; /** * @since 0.9.2 * @category Combinator */ export declare const toUnion: <E, A>(fa: D.Data<Ei.Either<E, A>>) => D.Data<E | A>; /** * @since 0.9.2 * @category URI */ export declare const URI = "@typed/fp/DataEither"; /** * @since 0.9.2 * @category URI */ export declare type URI = typeof URI; declare module 'fp-ts/HKT' { interface URItoKind2<E, A> { [URI]: DataEither<E, A>; } } declare module './HKT' { interface URItoVariance { [URI]: V<E, Contravariant>; } } /** * @since 0.9.2 * @category Constructor */ export declare const of: <A, E = never>(a: A) => D.Data<Ei.Either<E, A>>; /** * @since 0.9.2 * @category Instance */ export declare const Pointed: Pointed_.Pointed2<URI>; /** * @since 0.9.2 * @category Instance */ export declare const Functor: Functor_.Functor2<URI>; /** * @since 0.9.2 * @category Combinator */ export declare const bindTo: <N extends string>(name: N) => <E, A>(fa: DataEither<E, A>) => DataEither<E, { readonly [K in N]: A; }>; /** * @since 0.9.2 * @category Combinator */ export declare const flap: <A>(a: A) => <E, B>(fab: DataEither<E, (a: A) => B>) => DataEither<E, B>; /** * @since 0.9.2 * @category Combinator */ export declare const tupled: <E, A>(fa: DataEither<E, A>) => DataEither<E, readonly [A]>; /** * @since 0.9.2 * @category Instance */ export declare const Bifunctor: Bifunctor_.Bifunctor2<URI>; /** * @since 0.9.2 * @category Instance */ export declare const Apply: Apply_.Apply2<URI>; /** * @since 0.9.2 * @category Combinator */ export declare const apFirst: <E, B>(second: DataEither<E, B>) => <A>(first: DataEither<E, A>) => DataEither<E, A>; /** * @since 0.9.2 * @category Combinator */ export declare const apS: <N extends string, A, E, B>(name: Exclude<N, keyof A>, fb: DataEither<E, B>) => (fa: DataEither<E, A>) => DataEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B; }>; /** * @since 0.9.2 * @category Combinator */ export declare const apSecond: <E, B>(second: DataEither<E, B>) => <A>(first: DataEither<E, A>) => DataEither<E, B>; /** * @since 0.9.2 * @category Combinator */ export declare const apT: <E, B>(fb: DataEither<E, B>) => <A extends readonly unknown[]>(fas: DataEither<E, A>) => DataEither<E, readonly [...A, B]>; /** * @since 0.9.2 * @category Typeclass Constructor */ export declare const getSemigroup: <A, E>(S: Semigroup_.Semigroup<A>) => Semigroup_.Semigroup<DataEither<E, A>>; /** * @since 0.9.2 * @category Instance */ export declare const Applicative: Applicative_.Applicative2<URI>; /** * @since 0.9.2 * @category Instance */ export declare const Chain: Chain_.Chain2<URI>; /** * @since 0.9.2 * @category Combinator */ export declare const bind: <N extends string, A, E, B>(name: Exclude<N, keyof A>, f: (a: A) => DataEither<E, B>) => (ma: DataEither<E, A>) => DataEither<E, { readonly [K in N | keyof A]: K extends keyof A ? A[K] : B; }>; /** * @since 0.9.2 * @category Combinator */ export declare const chainFirst: <A, E, B>(f: (a: A) => DataEither<E, B>) => (first: DataEither<E, A>) => DataEither<E, A>; /** * @since 0.9.2 * @category Instance */ export declare const Monad: Monad_.Monad2<URI>; /** * @since 0.9.2 * @category Combinator */ export declare const chainRec: <A, E, B>(f: (value: A) => DataEither<E, Ei.Either<A, B>>) => (a: A) => DataEither<E, B>; /** * @since 0.9.2 * @category Instance */ export declare const ChainRec: ChainRec_.ChainRec2<URI>; /** * @since 0.9.2 * @category Instance */ export declare const MonadRec: MonadRec2<URI>; /** * @since 0.9.2 * @category Constructor */ export declare const fromEither: <E, A>(e: Ei.Either<E, A>) => DataEither<E, A>; /** * @since 0.9.2 * @category Instance */ export declare const FromEither: FEi.FromEither2<URI>; /** * @since 0.9.2 * @category Instance */ export declare const Alt: Alt_.Alt2<URI>; /** * @since 0.9.2 * @category Combinator */ export declare const chainEitherK: <A, E, B>(f: (a: A) => Ei.Either<E, B>) => (ma: DataEither<E, A>) => DataEither<E, B>; /** * @since 0.9.2 * @category Combinator */ export declare const chainOptionK: <E>(onNone: import("fp-ts/function").Lazy<E>) => <A, B>(f: (a: A) => import("fp-ts/Option").Option<B>) => (ma: DataEither<E, A>) => DataEither<E, B>; /** * @since 0.9.2 * @category Combinator */ export declare const filterOrElse: { <A, B extends A, E>(refinement: import("fp-ts/Refinement").Refinement<A, B>, onFalse: (a: A) => E): (ma: DataEither<E, A>) => DataEither<E, B>; <A_1, E_1>(predicate: import("fp-ts/Predicate").Predicate<A_1>, onFalse: (a: A_1) => E_1): <B_1 extends A_1>(mb: DataEither<E_1, B_1>) => DataEither<E_1, B_1>; }; /** * @since 0.9.2 * @category Combinator */ export declare const fromEitherK: <A extends readonly unknown[], E, B>(f: (...a: A) => Ei.Either<E, B>) => (...a: A) => DataEither<E, B>; /** * @since 0.9.2 * @category Combinator */ export declare const fromOption: <E>(onNone: import("fp-ts/function").Lazy<E>) => import("fp-ts/NaturalTransformation").NaturalTransformation12C<"Option", "@typed/fp/DataEither", E>; /** * @since 0.9.2 * @category Combinator */ export declare const fromOptionK: <E>(onNone: import("fp-ts/function").Lazy<E>) => <A extends readonly unknown[], B>(f: (...a: A) => import("fp-ts/Option").Option<B>) => (...a: A) => DataEither<E, B>; /** * @since 0.9.2 * @category Combinator */ export declare const fromPredicate: { <A, B extends A>(refinement: import("fp-ts/Refinement").Refinement<A, B>): (a: A) => DataEither<A, B>; <A_1>(predicate: import("fp-ts/Predicate").Predicate<A_1>): <B_1 extends A_1>(b: B_1) => DataEither<B_1, B_1>; }; /** * @since 0.12.1 * @category Consturctor */ export declare const noData: DataEither<never, never>; /** * @since 0.12.1 * @category Consturctor */ export declare const loading: DataEither<never, never>; /** * @since 0.12.1 * @category Constructor */ export declare const fromProgress: (progress: import("./Progress").Progress) => D.Data<Ei.Either<never, unknown>>; /** * @since 0.12.1 * @category Combinator */ export declare const toLoading: <E, A>(de: DataEither<E, A>) => DataEither<E, A>; /** * @since 0.12.1 * @category Constructor */ export declare const refresh: <A>(value: A, progress?: import("fp-ts/Option").Option<import("./Progress").Progress> | undefined) => D.Data<Ei.Either<never, A>>; /** * @since 0.12.1 * @category Constructor */ export declare const replete: <A>(value: A) => D.Data<Ei.Either<never, A>>; //# sourceMappingURL=DataEither.d.ts.map