/** * ```ts * interface IO { * (): A * } * ``` * * `IO` represents a non-deterministic synchronous computation that can cause side effects, yields a value of * type `A` and **never fails**. * * If you want to represent a synchronous computation that may fail, please see `IOEither`. * If you want to represent a synchronous computation that may yield nothing, please see `IOOption`. * * @since 2.0.0 */ import { Applicative1 } from './Applicative' import { Apply1 } from './Apply' import { Chain1 } from './Chain' import { ChainRec1 } from './ChainRec' import { FromIO1 } from './FromIO' import { Functor1 } from './Functor' import { Monad1 } from './Monad' import { MonadIO1 } from './MonadIO' import { Monoid } from './Monoid' import { Pointed1 } from './Pointed' import { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray' import { Semigroup } from './Semigroup' /** * @category model * @since 2.0.0 */ export interface IO { (): A } /** * `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: IO) => IO /** * @since 2.0.0 */ export declare const ap: (fa: IO) => (fab: IO<(a: A) => B>) => IO /** * @category constructors * @since 2.0.0 */ export declare const of: (a: A) => IO /** * 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) => IO) => (ma: IO) => IO /** * @category sequencing * @since 2.0.0 */ export declare const flatten: (mma: IO>) => IO /** * @category type lambdas * @since 2.0.0 */ export declare const URI = 'IO' /** * @category type lambdas * @since 2.0.0 */ export declare type URI = typeof URI declare module './HKT' { interface URItoKind { readonly [URI]: IO } } /** * @category instances * @since 2.7.0 */ export declare const Functor: Functor1 /** * @category mapping * @since 2.10.0 */ export declare const flap: (a: A) => (fab: IO<(a: A) => B>) => IO /** * @category instances * @since 2.10.0 */ export declare const Pointed: Pointed1 /** * @category instances * @since 2.10.0 */ export declare const Apply: Apply1 /** * Combine two effectful actions, keeping only the result of the first. * * @since 2.0.0 */ export declare const apFirst: (second: IO) => (first: IO) => IO /** * Combine two effectful actions, keeping only the result of the second. * * @since 2.0.0 */ export declare const apSecond: (second: IO) => (first: IO) => IO /** * @category instances * @since 2.7.0 */ export declare const Applicative: Applicative1 /** * @category instances * @since 2.10.0 */ export declare const Chain: Chain1 /** * @category instances * @since 2.7.0 */ export declare const Monad: Monad1 /** * 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) => IO) => (first: IO) => IO /** * @category zone of death * @since 2.7.0 * @deprecated */ export declare const fromIO: (fa: IO) => IO /** * @category instances * @since 2.7.0 */ export declare const MonadIO: MonadIO1 /** * @category instances * @since 2.7.0 */ export declare const ChainRec: ChainRec1 /** * @category instances * @since 2.10.0 */ export declare const FromIO: FromIO1 /** * @category do notation * @since 2.9.0 */ export declare const Do: IO<{}> /** * @category do notation * @since 2.8.0 */ export declare const bindTo: (name: N) => (fa: IO) => IO<{ readonly [K in N]: A }> declare const let_: ( name: Exclude, f: (a: A) => B ) => (fa: IO) => IO<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }> 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) => IO ) => (ma: IO) => IO<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }> /** * @category do notation * @since 2.8.0 */ export declare const apS: ( name: Exclude, fb: IO ) => (fa: IO) => IO<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }> /** * @since 2.11.0 */ export declare const ApT: IO /** * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyNonEmptyArrayWithIndex: ( f: (index: number, a: A) => IO ) => (as: ReadonlyNonEmptyArray) => IO> /** * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyArrayWithIndex: ( f: (index: number, a: A) => IO ) => (as: readonly A[]) => IO /** * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const traverseArrayWithIndex: ( f: (index: number, a: A) => IO ) => (as: ReadonlyArray) => IO> /** * Equivalent to `ReadonlyArray#traverse(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const traverseArray: (f: (a: A) => IO) => (as: readonly A[]) => IO /** * Equivalent to `ReadonlyArray#sequence(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const sequenceArray: (arr: ReadonlyArray>) => IO> /** * This instance is deprecated, use small, specific instances instead. * For example if a function needs a `Functor` instance, pass `IO.Functor` instead of `IO.io` * (where `IO` is from `import IO from 'fp-ts/IO'`) * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const io: Monad1 & MonadIO1 & ChainRec1 /** * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getSemigroup: (S: Semigroup) => Semigroup> /** * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getMonoid: (M: Monoid) => Monoid>