/** * @since 2.0.0 */ import { Alt3, Alt3C } from './Alt' import { Applicative3, Applicative3C } from './Applicative' import { Apply3 } from './Apply' import { Bifunctor3 } from './Bifunctor' import { Chain3 } from './Chain' import { Compactable3C } from './Compactable' import * as E from './Either' import { Filterable3C } from './Filterable' import { FromEither3 } from './FromEither' import { FromReader3 } from './FromReader' import { Lazy } from './function' import { Functor3 } from './Functor' import { Monad3, Monad3C } from './Monad' import { MonadThrow3, MonadThrow3C } from './MonadThrow' import { Monoid } from './Monoid' import { Option } from './Option' import { Pointed3 } from './Pointed' import { Predicate } from './Predicate' import * as R from './Reader' import { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray' import { Refinement } from './Refinement' import { Semigroup } from './Semigroup' import Reader = R.Reader import Either = E.Either /** * @category model * @since 2.0.0 */ export interface ReaderEither extends Reader> {} /** * @category constructors * @since 2.0.0 */ export declare const left: (e: E) => ReaderEither /** * @category constructors * @since 2.0.0 */ export declare const right: (a: A) => ReaderEither /** * @category constructors * @since 2.0.0 */ export declare const rightReader: (ma: Reader) => ReaderEither /** * @category constructors * @since 2.0.0 */ export declare const leftReader: (me: Reader) => ReaderEither /** * @category conversions * @since 2.0.0 */ export declare const fromEither: (fa: Either) => ReaderEither /** * @category conversions * @since 2.11.0 */ export declare const fromReader: (fa: Reader) => ReaderEither /** * @category pattern matching * @since 2.10.0 */ export declare const match: ( onLeft: (e: E) => B, onRight: (a: A) => B ) => (ma: ReaderEither) => Reader /** * 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 declare const matchW: ( onLeft: (e: E) => B, onRight: (a: A) => C ) => (ma: Reader>) => Reader /** * The `E` suffix (short for **E**ffect) means that the handlers return an effect (`Reader`). * * @category pattern matching * @since 2.10.0 */ export declare const matchE: ( onLeft: (e: E) => Reader, onRight: (a: A) => Reader ) => (ma: ReaderEither) => Reader /** * Alias of [`matchE`](#matche). * * @category pattern matching * @since 2.0.0 */ export declare const fold: ( onLeft: (e: E) => R.Reader, onRight: (a: A) => R.Reader ) => (ma: ReaderEither) => R.Reader /** * 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 declare const matchEW: ( onLeft: (e: E) => Reader, onRight: (a: A) => Reader ) => (ma: ReaderEither) => Reader /** * Alias of [`matchEW`](#matchew). * * @category pattern matching * @since 2.10.0 */ export declare const foldW: ( onLeft: (e: E) => R.Reader, onRight: (a: A) => R.Reader ) => (ma: ReaderEither) => R.Reader /** * @category error handling * @since 2.0.0 */ export declare const getOrElse: (onLeft: (e: E) => Reader) => (ma: ReaderEither) => Reader /** * 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.6.0 */ export declare const getOrElseW: ( onLeft: (e: E) => Reader ) => (ma: ReaderEither) => Reader /** * @category conversions * @since 2.10.0 */ export declare const toUnion: (fa: ReaderEither) => Reader /** * Changes the value of the local context during the execution of the action `ma` (similar to `Contravariant`'s * `contramap`). * * @since 2.0.0 */ export declare const local: (f: (r2: R2) => R1) => (ma: ReaderEither) => ReaderEither /** * Less strict version of [`asksReaderEither`](#asksreadereither). * * The `W` suffix (short for **W**idening) means that the environment types will be merged. * * @category constructors * @since 2.11.0 */ export declare const asksReaderEitherW: ( f: (r1: R1) => ReaderEither ) => ReaderEither /** * Effectfully accesses the environment. * * @category constructors * @since 2.11.0 */ export declare const asksReaderEither: (f: (r: R) => ReaderEither) => ReaderEither /** * @category error handling * @since 2.0.0 */ export declare const orElse: ( onLeft: (e: E1) => ReaderEither ) => (ma: ReaderEither) => ReaderEither /** * Less strict version of [`orElse`](#orelse). * * The `W` suffix (short for **W**idening) means that the environment types and the return types will be merged. * * @category error handling * @since 2.10.0 */ export declare const orElseW: ( onLeft: (e: E1) => ReaderEither ) => (ma: ReaderEither) => ReaderEither /** * @category error handling * @since 2.11.0 */ export declare const orElseFirst: ( onLeft: (e: E) => ReaderEither ) => (ma: ReaderEither) => ReaderEither /** * The `W` suffix (short for **W**idening) means that the environment types and the return types will be merged. * * @category error handling * @since 2.11.0 */ export declare const orElseFirstW: ( onLeft: (e: E1) => ReaderEither ) => (ma: ReaderEither) => ReaderEither /** * @category error handling * @since 2.11.0 */ export declare const orLeft: ( onLeft: (e: E1) => Reader ) => (fa: ReaderEither) => ReaderEither /** * @since 2.0.0 */ export declare const swap: (ma: ReaderEither) => ReaderEither /** * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` whose argument and return types * use the type constructor `F` to represent some computational context. * * @category mapping * @since 2.0.0 */ export declare const map: (f: (a: A) => B) => (fa: ReaderEither) => ReaderEither /** * Map a pair of functions over the two last type arguments of the bifunctor. * * @category mapping * @since 2.0.0 */ export declare const bimap: ( f: (e: E) => G, g: (a: A) => B ) => (fa: ReaderEither) => ReaderEither /** * Map a function over the second type argument of a bifunctor. * * @category error handling * @since 2.0.0 */ export declare const mapLeft: (f: (e: E) => G) => (fa: ReaderEither) => ReaderEither /** * @since 2.0.0 */ export declare const ap: ( fa: ReaderEither ) => (fab: ReaderEither B>) => ReaderEither /** * Less strict version of [`ap`](#ap). * * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged. * * @since 2.8.0 */ export declare const apW: ( fa: ReaderEither ) => (fab: ReaderEither B>) => ReaderEither /** * @category constructors * @since 2.8.5 */ export declare const of: (a: A) => ReaderEither /** * Composes computations in sequence, using the return value of one computation to determine the next computation. * * @category sequencing * @since 2.0.0 */ export declare const chain: ( f: (a: A) => ReaderEither ) => (ma: ReaderEither) => ReaderEither /** * Less strict version of [`chain`](#chain). * * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged. * * @category sequencing * @since 2.6.0 */ export declare const chainW: ( f: (a: A) => ReaderEither ) => (ma: ReaderEither) => ReaderEither /** * Less strict version of [`flatten`](#flatten). * * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged. * * @category sequencing * @since 2.11.0 */ export declare const flattenW: ( mma: ReaderEither> ) => ReaderEither /** * @category sequencing * @since 2.0.0 */ export declare const flatten: (mma: ReaderEither>) => ReaderEither /** * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to * types of kind `* -> *`. * * @category error handling * @since 2.0.0 */ export declare const alt: ( that: () => ReaderEither ) => (fa: ReaderEither) => ReaderEither /** * Less strict version of [`alt`](#alt). * * The `W` suffix (short for **W**idening) means that the environment, the error and the return types will be merged. * * @category error handling * @since 2.9.0 */ export declare const altW: ( that: () => ReaderEither ) => (fa: ReaderEither) => ReaderEither /** * @since 2.7.0 */ export declare const throwError: MonadThrow3['throwError'] /** * @category type lambdas * @since 2.0.0 */ export declare const URI = 'ReaderEither' /** * @category type lambdas * @since 2.0.0 */ export declare type URI = typeof URI declare module './HKT' { interface URItoKind3 { readonly [URI]: ReaderEither } } /** * @category filtering * @since 2.10.0 */ export declare const getCompactable: (M: Monoid) => Compactable3C<'ReaderEither', E> /** * @category filtering * @since 2.10.0 */ export declare function getFilterable(M: Monoid): Filterable3C /** * The default [`Applicative`](#applicative) instance returns the first error, if you want to * get all errors you need to provide a way to concatenate them via a `Semigroup`. * * See [`getApplicativeValidation`](./Either.ts.html#getapplicativevalidation). * * @category error handling * @since 2.7.0 */ export declare function getApplicativeReaderValidation(S: Semigroup): Applicative3C /** * The default [`Alt`](#alt) instance returns the last error, if you want to * get all errors you need to provide a way to concatenate them via a `Semigroup`. * * See [`getAltValidation`](./Either.ts.html#getaltvalidation). * * @category error handling * @since 2.7.0 */ export declare function getAltReaderValidation(S: Semigroup): Alt3C /** * @category instances * @since 2.7.0 */ export declare const Functor: Functor3 /** * @category mapping * @since 2.10.0 */ export declare const flap: (a: A) => (fab: ReaderEither B>) => ReaderEither /** * @category instances * @since 2.10.0 */ export declare const Pointed: Pointed3 /** * @category instances * @since 2.10.0 */ export declare const Apply: Apply3 /** * Combine two effectful actions, keeping only the result of the first. * * @since 2.0.0 */ export declare const apFirst: ( second: ReaderEither ) => (first: ReaderEither) => ReaderEither /** * Less strict version of [`apFirst`](#apfirst) * * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged. * * @since 2.12.0 */ export declare const apFirstW: ( second: ReaderEither ) => (first: ReaderEither) => ReaderEither /** * Combine two effectful actions, keeping only the result of the second. * * @since 2.0.0 */ export declare const apSecond: ( second: ReaderEither ) => (first: ReaderEither) => ReaderEither /** * Less strict version of [`apSecond`](#apsecond) * * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged. * * @since 2.12.0 */ export declare const apSecondW: ( second: ReaderEither ) => (first: ReaderEither) => ReaderEither /** * @category instances * @since 2.7.0 */ export declare const Applicative: Applicative3 /** * @category instances * @since 2.10.0 */ export declare const Chain: Chain3 /** * @category instances * @since 2.7.0 */ export declare const Monad: Monad3 /** * 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.0.0 */ export declare const chainFirst: ( f: (a: A) => ReaderEither ) => (ma: ReaderEither) => ReaderEither /** * Less strict version of [`chainFirst`](#chainfirst) * * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged. * * @category sequencing * @since 2.8.0 */ export declare const chainFirstW: ( f: (a: A) => ReaderEither ) => (ma: ReaderEither) => ReaderEither /** * @category instances * @since 2.7.0 */ export declare const Bifunctor: Bifunctor3 /** * @category instances * @since 2.7.0 */ export declare const Alt: Alt3 /** * @category instances * @since 2.11.0 */ export declare const FromReader: FromReader3 /** * Reads the current context. * * @category constructors * @since 2.0.0 */ export declare const ask: () => ReaderEither /** * Projects a value from the global context in a `ReaderEither`. * * @category constructors * @since 2.0.0 */ export declare const asks: (f: (r: R) => A) => ReaderEither /** * @category lifting * @since 2.11.0 */ export declare const fromReaderK: , R, B>( f: (...a: A) => Reader ) => (...a: A) => ReaderEither /** * @category sequencing * @since 2.11.0 */ export declare const chainReaderK: ( f: (a: A) => Reader ) => (ma: ReaderEither) => ReaderEither /** * 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 */ export declare const chainReaderKW: ( f: (a: A) => Reader ) => (ma: ReaderEither) => ReaderEither /** * @category sequencing * @since 2.11.0 */ export declare const chainFirstReaderK: ( f: (a: A) => Reader ) => (ma: ReaderEither) => ReaderEither /** * 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 */ export declare const chainFirstReaderKW: ( f: (a: A) => Reader ) => (ma: ReaderEither) => ReaderEither /** * @category instances * @since 2.7.0 */ export declare const MonadThrow: MonadThrow3 /** * @category instances * @since 2.10.0 */ export declare const FromEither: FromEither3 /** * @category conversions * @since 2.0.0 */ export declare const fromOption: (onNone: Lazy) => (fa: Option) => ReaderEither /** * @category lifting * @since 2.10.0 */ export declare const fromOptionK: ( onNone: Lazy ) => , B>(f: (...a: A) => Option) => (...a: A) => ReaderEither /** * @category sequencing * @since 2.10.0 */ export declare const chainOptionK: ( onNone: Lazy ) => (f: (a: A) => Option) => (ma: ReaderEither) => ReaderEither /** * @category sequencing * @since 2.4.0 */ export declare const chainEitherK: ( f: (a: A) => E.Either ) => (ma: ReaderEither) => ReaderEither /** * Less strict version of [`chainEitherK`](#chaineitherk). * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @category sequencing * @since 2.6.1 */ export declare const chainEitherKW: ( f: (a: A) => Either ) => (ma: ReaderEither) => ReaderEither /** * @category sequencing * @since 2.12.0 */ export declare const chainFirstEitherK: ( f: (a: A) => E.Either ) => (ma: ReaderEither) => ReaderEither /** * Less strict version of [`chainFirstEitherK`](#chainfirsteitherk). * * The `W` suffix (short for **W**idening) means that the environment types will be merged. * * @category sequencing * @since 2.12.0 */ export declare const chainFirstEitherKW: ( f: (a: A) => Either ) => (ma: ReaderEither) => ReaderEither /** * @category lifting * @since 2.0.0 */ export declare const fromPredicate: { (refinement: Refinement, onFalse: (a: A) => E): (a: A) => ReaderEither (predicate: Predicate, onFalse: (a: A) => E): (b: B) => ReaderEither (predicate: Predicate, onFalse: (a: A) => E): (a: A) => ReaderEither } /** * @category filtering * @since 2.0.0 */ export declare const filterOrElse: { (refinement: Refinement, onFalse: (a: A) => E): ( ma: ReaderEither ) => ReaderEither (predicate: Predicate, onFalse: (a: A) => E): ( mb: ReaderEither ) => ReaderEither (predicate: Predicate, onFalse: (a: A) => E): (ma: ReaderEither) => ReaderEither } /** * Less strict version of [`filterOrElse`](#filterorelse). * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @category filtering * @since 2.9.0 */ export declare const filterOrElseW: { (refinement: Refinement, onFalse: (a: A) => E2): ( ma: ReaderEither ) => ReaderEither (predicate: Predicate, onFalse: (a: A) => E2): ( mb: ReaderEither ) => ReaderEither (predicate: Predicate, onFalse: (a: A) => E2): ( ma: ReaderEither ) => ReaderEither } /** * @category lifting * @since 2.4.0 */ export declare const fromEitherK: , B>( f: (...a: A) => E.Either ) => (...a: A) => ReaderEither /** * @category do notation * @since 2.9.0 */ export declare const Do: ReaderEither /** * @category do notation * @since 2.8.0 */ export declare const bindTo: ( name: N ) => (fa: ReaderEither) => ReaderEither declare const let_: ( name: Exclude, f: (a: A) => B ) => ( fa: ReaderEither ) => ReaderEither export { /** * @category do notation * @since 2.13.0 */ let_ as let } /** * @category do notation * @since 2.8.0 */ export declare const bind: ( name: Exclude, f: (a: A) => ReaderEither ) => (ma: ReaderEither) => ReaderEither /** * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged. * * @category do notation * @since 2.8.0 */ export declare const bindW: ( name: Exclude, f: (a: A) => ReaderEither ) => ( fa: ReaderEither ) => ReaderEither< R1 & R2, E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B } > /** * @category do notation * @since 2.8.0 */ export declare const apS: ( name: Exclude, fb: ReaderEither ) => (fa: ReaderEither) => ReaderEither /** * Less strict version of [`apS`](#aps). * * The `W` suffix (short for **W**idening) means that the environment types and the error types will be merged. * * @category do notation * @since 2.8.0 */ export declare const apSW: ( name: Exclude, fb: ReaderEither ) => ( fa: ReaderEither ) => ReaderEither< R1 & R2, E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B } > /** * @since 2.11.0 */ export declare const ApT: ReaderEither /** * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyNonEmptyArrayWithIndex: ( f: (index: number, a: A) => ReaderEither ) => (as: ReadonlyNonEmptyArray) => ReaderEither> /** * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyArrayWithIndex: ( f: (index: number, a: A) => ReaderEither ) => (as: readonly A[]) => ReaderEither /** * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const traverseArrayWithIndex: ( f: (index: number, a: A) => ReaderEither ) => (as: ReadonlyArray) => ReaderEither> /** * Equivalent to `ReadonlyArray#traverse(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const traverseArray: ( f: (a: A) => ReaderEither ) => (as: readonly A[]) => ReaderEither /** * Equivalent to `ReadonlyArray#sequence(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const sequenceArray: ( arr: ReadonlyArray> ) => ReaderEither> /** * This instance is deprecated, use small, specific instances instead. * For example if a function needs a `Functor` instance, pass `RE.Functor` instead of `RE.readerEither` * (where `R` is from `import R from 'fp-ts/ReaderEither'`) * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const readerEither: Monad3 & Bifunctor3 & Alt3 & MonadThrow3 /** * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getApplySemigroup: (S: Semigroup) => Semigroup> /** * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getApplyMonoid: (M: Monoid) => Monoid> /** * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getSemigroup: (S: Semigroup) => Semigroup> /** * Use [`getApplicativeReaderValidation`](#getapplicativereadervalidation) and [`getAltReaderValidation`](#getaltreadervalidation) instead. * * @category zone of death * @since 2.3.0 * @deprecated */ export declare function getReaderValidation( SE: Semigroup ): Monad3C & Bifunctor3 & Alt3C & MonadThrow3C