/** * ```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.js'; import { Apply1 } from './Apply.js'; import * as chainable from './Chain.js'; import { ChainRec1 } from './ChainRec.js'; import { FromIO1 } from './FromIO.js'; import { Functor1 } from './Functor.js'; import { Monad1 } from './Monad.js'; import { MonadIO1 } from './MonadIO.js'; import { Monoid } from './Monoid.js'; import { Pointed1 } from './Pointed.js'; import { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray.js'; import { Semigroup } from './Semigroup.js'; /** * @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; /** * @category sequencing * @since 2.14.0 */ export declare const flatMap: { (f: (a: A) => IO): (ma: IO) => IO; (ma: IO, f: (a: A) => 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 type URI = typeof URI; declare module './HKT.js' { interface URItoKind { readonly [URI]: IO; } } /** * @category instances * @since 2.7.0 */ export declare const Functor: Functor1; /** * Maps the value to the specified constant value. * * @category mapping * @since 2.16.0 */ export declare const as: { (a: A): <_>(self: IO<_>) => IO; <_, A>(self: IO<_>, a: A): IO; }; /** * Maps the value to the void constant value. * * @category mapping * @since 2.16.0 */ export declare const asUnit: <_>(self: IO<_>) => IO; /** * @category mapping * @since 2.10.0 */ export declare const flap: (a: A) => (fab: import("./HKT.js").Kind<"IO", (a: A) => B>) => import("./HKT.js").Kind<"IO", B>; /** * @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: import("./HKT.js").Kind<"IO", A>) => import("./HKT.js").Kind<"IO", A>; /** * Combine two effectful actions, keeping only the result of the second. * * @since 2.0.0 */ export declare const apSecond: (second: IO) => (first: import("./HKT.js").Kind<"IO", A>) => import("./HKT.js").Kind<"IO", B>; /** * @category instances * @since 2.7.0 */ export declare const Applicative: Applicative1; /** * @category instances * @since 2.10.0 */ export declare const Chain: chainable.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 combinators * @since 2.15.0 */ export declare const tap: { (self: IO, f: (a: A) => IO<_>): IO; (f: (a: A) => IO<_>): (self: 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: import("./HKT.js").Kind<"IO", A>) => import("./HKT.js").Kind<"IO", { readonly [K in N]: A; }>; declare const let_: (name: Exclude, f: (a: A) => B) => (fa: import("./HKT.js").Kind<"IO", A>) => import("./HKT.js").Kind<"IO", { readonly [K in keyof A | N]: 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) => import("./HKT.js").Kind<"IO", B>) => (ma: import("./HKT.js").Kind<"IO", A>) => import("./HKT.js").Kind<"IO", { 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: IO) => (fa: import("./HKT.js").Kind<"IO", A>) => import("./HKT.js").Kind<"IO", { readonly [K in keyof A | N]: 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: ReadonlyArray) => 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: ReadonlyArray) => IO>); /** * Equivalent to `ReadonlyArray#sequence(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const sequenceArray: (arr: ReadonlyArray>) => IO>; /** * Alias of `flatMap`. * * @category legacy * @since 2.0.0 */ export declare const chain: (f: (a: A) => IO) => (ma: IO) => IO; /** * Alias of `tap`. * * @category legacy * @since 2.0.0 */ export declare const chainFirst: (f: (a: A) => IO) => (first: IO) => 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>;