/** * @typed/fp/Fx is a generator-based do-notation for single-shot data types. * * @since 0.13.0 */ import { Applicative2 } from 'fp-ts/Applicative'; import { Apply2 } from 'fp-ts/Apply'; import { ChainRec2 } from 'fp-ts/ChainRec'; import { Either } from 'fp-ts/Either'; import { FromIO2 } from 'fp-ts/FromIO'; import { Functor2 } from 'fp-ts/Functor'; import { IO } from 'fp-ts/IO'; import { Monad2 } from 'fp-ts/Monad'; import { Pointed2 } from 'fp-ts/Pointed'; import { A } from 'ts-toolbelt'; /** * Fx is a generator-based abstraction for do-notation for any single-shot * effect. Due to the mutable nature of generators however, we cannot support this syntax * for multi-shot effects like reactive Streams/Observables. Most of the effects you * likely use are single-shot like Option/Either/Task. * * An Fx is a set of Effects which are being `yield`ed from the Generator. * This can be a powerful way to construct algorithms separate from their interpretation. * * Fx's Result parameter is the secret to getting type-safety by using yield* when running an Fx. * * @category Model * @since 0.13.0 */ export interface Fx { readonly [Symbol.iterator]: () => Generator; } /** * Extract the effects being performed within an Fx * @category Type-level * @since 0.13.0 */ export declare type GetEffects = A extends Fx ? IsNever extends false ? R : unknown : unknown; declare type IsNever = A.Equals<[never], [A]> extends 1 ? true : false; /** * Extract the result being performed within an Fx * @category Type-level * @since 0.13.0 */ export declare type GetResult = A extends Fx ? R : never; /** * Extract the values being returned to the internal Fx * @category Type-level * @since 0.13.0 */ export declare type GetNext = A extends Fx ? R : never; /** * Extract the values being returned to the internal Fx * @category Combinator * @since 0.13.0 */ export declare function doFx>(generatorFn: () => G): Fx, GetResult, GetNext>; /** * An Fx which has no Effects or they have all been accounted for. * @category Model * @since 0.13.0 */ export interface Pure extends Fx { } /** * @category Constructor * @since 0.13.0 */ export declare const pure: (value: A) => Pure; /** * @category Constructor * @since 0.13.0 */ export declare const fromIO: (io: IO) => Pure; /** * @category URI * @since 0.13.0 */ export declare const URI = "@typed/fp/Fx"; /** * @category URI * @since 0.13.0 */ export declare type URI = typeof URI; declare module 'fp-ts/HKT' { interface URItoKind2 { [URI]: Fx; } } /** * @category Combinator * @since 0.13.0 */ export declare const map: (f: (value: A) => B) => (fa: Fx) => Fx; /** * @category Instance * @since 0.13.0 */ export declare const Functor: Functor2; /** * @category Constructor * @since 0.13.0 */ export declare const of: (value: A) => Pure; /** * @category Instance * @since 0.13.0 */ export declare const Pointed: Pointed2; /** * @category Combinator * @since 0.13.0 */ export declare const chain: (f: (value: A) => Fx) => (fa: Fx) => Fx; /** * @category Instance * @since 0.13.0 */ export declare const Monad: Monad2; /** * @category Combinator * @since 0.13.0 */ export declare const chainRec: (f: (value: A) => Fx, unknown>) => (value: A) => Fx; /** * @category Instance * @since 0.13.0 */ export declare const ChainRec: ChainRec2; /** * @category Combinator * @since 0.13.0 */ export declare const ap: (fa: Fx) => (fab: Fx B, unknown>) => Fx; /** * @category Instance * @since 0.13.0 */ export declare const Apply: Apply2; /** * @category Instance * @since 0.13.0 */ export declare const Applicative: Applicative2; /** * @category Instance * @since 0.13.0 */ export declare const FromIO: FromIO2; export {}; //# sourceMappingURL=Fx.d.ts.map