/** * @since 2.10.0 */ import { Alt1 } from './Alt' import { Alternative1 } from './Alternative' import { Applicative1 } from './Applicative' import { Apply1 } from './Apply' import * as chainable from './Chain' import { Compactable1 } from './Compactable' import { Either } from './Either' import { Filterable1 } from './Filterable' import { FromEither1 } from './FromEither' import { FromIO1 } from './FromIO' import { FromTask1 } from './FromTask' import { LazyArg } from './function' import { Functor1 } from './Functor' import { IO } from './IO' import { Monad1 } from './Monad' import { MonadIO1 } from './MonadIO' import { MonadTask1 } from './MonadTask' import * as O from './Option' import { Pointed1 } from './Pointed' import { Predicate } from './Predicate' import { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray' import { Refinement } from './Refinement' import { Separated } from './Separated' import * as T from './Task' import { TaskEither } from './TaskEither' import { Zero1 } from './Zero' import Task = T.Task import Option = O.Option /** * @category model * @since 2.10.0 */ export interface TaskOption extends Task> {} /** * @category constructors * @since 2.10.0 */ export declare const some: (a: A) => TaskOption /** * @category lifting * @since 2.10.0 */ export declare const fromPredicate: { (refinement: Refinement): (a: A) => TaskOption (predicate: Predicate): (b: B) => TaskOption (predicate: Predicate): (a: A) => TaskOption } /** * @category conversions * @since 2.10.0 */ export declare const fromOption: (fa: Option) => TaskOption /** * @category conversions * @since 2.10.0 */ export declare const fromEither: (fa: Either) => TaskOption /** * @category conversions * @since 2.10.0 */ export declare const fromIO: (fa: IO) => TaskOption /** * @category conversions * @since 2.10.0 */ export declare const fromTask: (fa: Task) => TaskOption /** * @category conversions * @since 2.11.0 */ export declare const fromTaskEither: (fa: TaskEither) => TaskOption /** * @category pattern matching * @since 2.10.0 */ export declare const match: (onNone: () => B, onSome: (a: A) => B) => (ma: TaskOption) => Task /** * 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: (onNone: () => B, onSome: (a: A) => C) => (ma: TaskOption) => Task /** * The `E` suffix (short for **E**ffect) means that the handlers return an effect (`Task`). * * @category pattern matching * @since 2.10.0 */ export declare const matchE: (onNone: () => Task, onSome: (a: A) => Task) => (ma: TaskOption) => Task /** * Alias of [`matchE`](#matche). * * @category pattern matching * @since 2.10.0 */ export declare const fold: ( onNone: () => T.Task, onSome: (a: A) => T.Task ) => (ma: TaskOption) => T.Task /** * 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: ( onNone: () => Task, onSome: (a: A) => Task ) => (ma: TaskOption) => Task /** * Alias of [`matchEW`](#matchew). * * @category pattern matching * @since 2.10.0 */ export declare const foldW: ( onNone: () => T.Task, onSome: (a: A) => T.Task ) => (ma: TaskOption) => T.Task /** * @category error handling * @since 2.10.0 */ export declare const getOrElse: (onNone: LazyArg>) => (fa: TaskOption) => Task /** * 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.10.0 */ export declare const getOrElseW: (onNone: LazyArg>) => (ma: TaskOption) => Task /** * @category conversions * @since 2.10.0 */ export declare const fromNullable: (a: A) => TaskOption> /** * Transforms a `Promise` that may reject to a `Promise` that never rejects and returns an `Option` instead. * * See also [`tryCatchK`](#trycatchk). * * @category interop * @since 2.10.0 */ export declare const tryCatch: (f: LazyArg>) => TaskOption /** * Converts a function returning a `Promise` to one returning a `TaskOption`. * * @category interop * @since 2.10.0 */ export declare const tryCatchK: ( f: (...a: A) => Promise ) => (...a: A) => TaskOption /** * @category lifting * @since 2.10.0 */ export declare const fromNullableK: , B>( f: (...a: A) => B | null | undefined ) => (...a: A) => TaskOption> /** * @category sequencing * @since 2.10.0 */ export declare const chainNullableK: ( f: (a: A) => B | null | undefined ) => (ma: TaskOption) => TaskOption> /** * @category lifting * @since 2.10.0 */ export declare const fromOptionK: , B>( f: (...a: A) => Option ) => (...a: A) => TaskOption /** * @category sequencing * @since 2.10.0 */ export declare const chainOptionK: (f: (a: A) => Option) => (ma: TaskOption) => TaskOption /** * `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.10.0 */ export declare const map: (f: (a: A) => B) => (fa: TaskOption) => TaskOption /** * @since 2.10.0 */ export declare const ap: (fa: TaskOption) => (fab: TaskOption<(a: A) => B>) => TaskOption /** * @category constructors * @since 2.10.0 */ export declare const of: (a: A) => TaskOption /** * @category sequencing * @since 2.14.0 */ export declare const flatMap: { (f: (a: A) => TaskOption): (ma: TaskOption) => TaskOption (ma: TaskOption, f: (a: A) => TaskOption): TaskOption } /** * @category sequencing * @since 2.16.0 */ export declare const flatMapIO: { (f: (a: A) => IO): (self: TaskOption) => TaskOption (self: TaskOption, f: (a: A) => IO): TaskOption } /** * @category sequencing * @since 2.16.0 */ export declare const flatMapTask: { (f: (a: A) => Task): (self: TaskOption) => TaskOption (self: TaskOption, f: (a: A) => Task): TaskOption } /** * @category sequencing * @since 2.10.0 */ export declare const flatten: (mma: TaskOption>) => TaskOption /** * @category error handling * @since 2.10.0 */ export declare const alt: (second: LazyArg>) => (first: TaskOption) => TaskOption /** * Less strict version of [`alt`](#alt). * * The `W` suffix (short for **W**idening) means that the return types will be merged. * * @category error handling * @since 2.10.0 */ export declare const altW: (second: LazyArg>) => (first: TaskOption) => TaskOption /** * @since 2.10.0 */ export declare const zero: () => TaskOption /** * @category constructors * @since 2.10.0 */ export declare const none: TaskOption /** * @category filtering * @since 2.10.0 */ export declare const compact: Compactable1['compact'] /** * @category filtering * @since 2.10.0 */ export declare const separate: Compactable1['separate'] /** * @category filtering * @since 2.10.0 */ export declare const filter: { (refinement: Refinement): (fb: TaskOption) => TaskOption (predicate: Predicate): (fb: TaskOption) => TaskOption (predicate: Predicate): (fa: TaskOption) => TaskOption } /** * @category filtering * @since 2.10.0 */ export declare const filterMap: (f: (a: A) => Option) => (fga: TaskOption) => TaskOption /** * @category filtering * @since 2.10.0 */ export declare const partition: { (refinement: Refinement): (fb: TaskOption) => Separated, TaskOption> (predicate: Predicate): (fb: TaskOption) => Separated, TaskOption> (predicate: Predicate): (fa: TaskOption) => Separated, TaskOption> } /** * @category filtering * @since 2.10.0 */ export declare const partitionMap: ( f: (a: A) => Either ) => (fa: TaskOption) => Separated, TaskOption> /** * @category type lambdas * @since 2.10.0 */ export declare const URI = 'TaskOption' /** * @category type lambdas * @since 2.10.0 */ export type URI = typeof URI declare module './HKT' { interface URItoKind { readonly [URI]: TaskOption } } /** * @category instances * @since 2.10.0 */ export declare const Functor: Functor1 /** * Maps the `Some` value of this `TaskOption` to the specified constant value. * * @category mapping * @since 2.16.0 */ export declare const as: { (a: A): <_>(self: TaskOption<_>) => TaskOption <_, A>(self: TaskOption<_>, a: A): TaskOption } /** * Maps the `Some` value of this `TaskOption` to the void constant value. * * @category mapping * @since 2.16.0 */ export declare const asUnit: <_>(self: TaskOption<_>) => TaskOption /** * @category mapping * @since 2.10.0 */ export declare const flap: (a: A) => (fab: TaskOption<(a: A) => B>) => TaskOption /** * @category instances * @since 2.10.0 */ export declare const Pointed: Pointed1 /** * Runs computations in parallel. * * @category instances * @since 2.10.0 */ export declare const ApplyPar: Apply1 /** * Combine two effectful actions, keeping only the result of the first. * * @since 2.10.0 */ export declare const apFirst: (second: TaskOption) => (first: TaskOption) => TaskOption /** * Combine two effectful actions, keeping only the result of the second. * * @since 2.10.0 */ export declare const apSecond: (second: TaskOption) => (first: TaskOption) => TaskOption /** * Runs computations in parallel. * * @category instances * @since 2.10.0 */ export declare const ApplicativePar: Applicative1 /** * Runs computations sequentially. * * @category instances * @since 2.10.0 */ export declare const ApplySeq: Apply1 /** * Runs computations sequentially. * * @category instances * @since 2.10.0 */ export declare const ApplicativeSeq: Applicative1 /** * @category instances * @since 2.10.0 */ export declare const Chain: chainable.Chain1 /** * @category instances * @since 2.11.0 */ export declare const FromEither: FromEither1 /** * @category instances * @since 2.10.0 */ export declare const FromIO: FromIO1 /** * @category instances * @since 2.10.0 */ export declare const FromTask: FromTask1 /** * 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: TaskOption, f: (a: A) => TaskOption<_>): TaskOption (f: (a: A) => TaskOption<_>): (self: TaskOption) => TaskOption } /** * Composes computations in sequence, using the return value of one computation to determine the next computation and * keeping only the result of the first. * * @example * import { pipe } from 'fp-ts/function' * import * as TO from 'fp-ts/TaskOption' * import * as O from 'fp-ts/Option' * import * as E from 'fp-ts/Either' * * const compute = (value: number) => pipe( * TO.of(value), * TO.tapEither((value) => value > 0 ? E.right('ok') : E.left('error')), * ) * * async function test() { * assert.deepStrictEqual(await compute(1)(), O.of(1)) * assert.deepStrictEqual(await compute(-1)(), O.none) * } * * test() * * @category combinators * @since 2.16.0 */ export declare const tapEither: { (f: (a: A) => Either): (self: TaskOption) => TaskOption (self: TaskOption, f: (a: A) => Either): TaskOption } /** * Composes computations in sequence, using the return value of one computation to determine the next computation and * keeping only the result of the first. * * @example * import { pipe } from 'fp-ts/function' * import * as TO from 'fp-ts/TaskOption' * import * as O from 'fp-ts/Option' * import * as Console from 'fp-ts/Console' * * * // Will produce `Hello, fp-ts` to the stdout * const effectA = TO.tapIO( * TO.of(1), * (value) => Console.log(`Hello, ${value}`) * ) * * // No output to the stdout * const effectB = pipe( * TO.none as TO.TaskOption, * TO.tapIO((value) => Console.log(`Hello, ${value}`)) * ) * * async function test() { * assert.deepStrictEqual(await effectA(), O.of(1)) * assert.deepStrictEqual(await effectB(), O.none) * } * * test() * * @category combinators * @since 2.16.0 */ export declare const tapIO: { (f: (a: A) => IO<_>): (self: TaskOption) => TaskOption (self: TaskOption, f: (a: A) => IO<_>): TaskOption } /** * Composes computations in sequence, using the return value of one computation to determine the next computation and * keeping only the result of the first. * * @example * import * as TO from 'fp-ts/TaskOption' * import * as O from 'fp-ts/Option' * import * as T from 'fp-ts/Task' * * const effect = TO.tapIO( * TO.of(1), * (value) => T.of(value + 1) * ) * * async function test() { * assert.deepStrictEqual(await effect(), O.of(1)) * } * * test() * * @category combinators * @since 2.16.0 */ export declare const tapTask: { (f: (a: A) => Task<_>): (self: TaskOption) => TaskOption (self: TaskOption, f: (a: A) => Task<_>): TaskOption } /** * @category instances * @since 2.10.0 */ export declare const Alt: Alt1 /** * @category instances * @since 2.11.0 */ export declare const Zero: Zero1 /** * @category do notation * @since 2.11.0 */ export declare const guard: (b: boolean) => TaskOption /** * @category instances * @since 2.10.0 */ export declare const Alternative: Alternative1 /** * @category instances * @since 2.10.0 */ export declare const Monad: Monad1 /** * @category instances * @since 2.10.0 */ export declare const MonadIO: MonadIO1 /** * @category instances * @since 2.10.0 */ export declare const MonadTask: MonadTask1 /** * @category instances * @since 2.10.0 */ export declare const Compactable: Compactable1 /** * @category instances * @since 2.10.0 */ export declare const Filterable: Filterable1 /** * @category lifting * @since 2.10.0 */ export declare const fromIOK: , B>(f: (...a: A) => IO) => (...a: A) => TaskOption /** * Alias of `flatMapIO`. * * @category legacy * @since 2.10.0 */ export declare const chainIOK: (f: (a: A) => IO) => (first: TaskOption) => TaskOption /** * Alias of `tapIO`. * * @category legacy * @since 2.10.0 */ export declare const chainFirstIOK: (f: (a: A) => IO) => (first: TaskOption) => TaskOption /** * @category lifting * @since 2.12.0 */ export declare const fromEitherK: , B>( f: (...a: A) => Either ) => (...a: A) => TaskOption /** * @category sequencing * @since 2.12.0 */ export declare const chainEitherK: (f: (a: A) => Either) => (ma: TaskOption) => TaskOption /** * Alias of `tapEither`. * * @category legacy * @since 2.12.0 */ export declare const chainFirstEitherK: (f: (a: A) => Either) => (ma: TaskOption) => TaskOption /** * @category lifting * @since 2.10.0 */ export declare const fromTaskK: , B>( f: (...a: A) => T.Task ) => (...a: A) => TaskOption /** * Alias of `flatMapTask`. * * @category legacy * @since 2.10.0 */ export declare const chainTaskK: (f: (a: A) => T.Task) => (first: TaskOption) => TaskOption /** * Alias of `tapTask`. * * @category legacy * @since 2.10.0 */ export declare const chainFirstTaskK: (f: (a: A) => T.Task) => (first: TaskOption) => TaskOption /** * @category do notation * @since 2.10.0 */ export declare const Do: TaskOption<{}> /** * @category do notation * @since 2.10.0 */ export declare const bindTo: ( name: N ) => (fa: TaskOption) => TaskOption<{ readonly [K in N]: A }> declare const let_: ( name: Exclude, f: (a: A) => B ) => (fa: TaskOption) => TaskOption<{ 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.10.0 */ export declare const bind: ( name: Exclude, f: (a: A) => TaskOption ) => (ma: TaskOption) => TaskOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }> /** * @category do notation * @since 2.10.0 */ export declare const apS: ( name: Exclude, fb: TaskOption ) => (fa: TaskOption) => TaskOption<{ readonly [K in N | keyof A]: K extends keyof A ? A[K] : B }> /** * @since 2.11.0 */ export declare const ApT: TaskOption /** * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyNonEmptyArrayWithIndex: ( f: (index: number, a: A) => TaskOption ) => (as: ReadonlyNonEmptyArray) => TaskOption> /** * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyArrayWithIndex: ( f: (index: number, a: A) => TaskOption ) => (as: readonly A[]) => TaskOption /** * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyNonEmptyArrayWithIndexSeq: ( f: (index: number, a: A) => TaskOption ) => (as: ReadonlyNonEmptyArray) => TaskOption> /** * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyArrayWithIndexSeq: ( f: (index: number, a: A) => TaskOption ) => (as: readonly A[]) => TaskOption /** * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.10.0 */ export declare const traverseArrayWithIndex: ( f: (index: number, a: A) => TaskOption ) => (as: ReadonlyArray) => TaskOption> /** * Equivalent to `ReadonlyArray#traverse(Applicative)`. * * @category traversing * @since 2.10.0 */ export declare const traverseArray: ( f: (a: A) => TaskOption ) => (as: ReadonlyArray) => TaskOption> /** * Equivalent to `ReadonlyArray#sequence(Applicative)`. * * @category traversing * @since 2.10.0 */ export declare const sequenceArray: (as: ReadonlyArray>) => TaskOption> /** * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`. * * @category traversing * @since 2.10.0 */ export declare const traverseSeqArrayWithIndex: ( f: (index: number, a: A) => TaskOption ) => (as: ReadonlyArray) => TaskOption> /** * Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`. * * @category traversing * @since 2.10.0 */ export declare const traverseSeqArray: ( f: (a: A) => TaskOption ) => (as: ReadonlyArray) => TaskOption> /** * Equivalent to `ReadonlyArray#sequence(ApplicativeSeq)`. * * @category traversing * @since 2.10.0 */ export declare const sequenceSeqArray: (as: ReadonlyArray>) => TaskOption> /** * Alias of `flatMap`. * * @category legacy * @since 2.10.0 */ export declare const chain: (f: (a: A) => TaskOption) => (ma: TaskOption) => TaskOption /** * Alias of `tap`. * * @category legacy * @since 2.10.0 */ export declare const chainFirst: (f: (a: A) => TaskOption) => (first: TaskOption) => TaskOption