import { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from 'fp-ts/HKT'; import { Applicative, Applicative1, Applicative2, Applicative2C, Applicative3, Applicative3C, Applicative4 } from 'fp-ts/lib/Applicative'; import { Traversable1 } from 'fp-ts/lib/Traversable'; import { URI } from './uri'; /** * Given an iterating function that returns a {@link HKT}, `traverse` applies * the iterating function to each element of the {@link Stream} and then * {@link sequence}-s the results using the provided `Applicative`. * * E.g. suppose you have a {@link Stream} and you want to format each element * with a function that returns a result or an error as * `f = (a: A) => Either`, using `traverse` you can apply `f` to all * elements and directly obtain as a result an `Either>` * i.e. a `Stream` if all the results are `B`, or an `Error` if some of the * results are `Error`s. * * @export * @template F The category type. * @param {Applicative} F The applicative instance. * @return {(f: (a: A) => HKT) => (ta: Kind) => HKT>} A function * that will take a stream of given `HKT` and will return that `HKT` containing * a stream of its type. * * @category traversing * @__PURE__ */ export declare function traverse(F: Applicative3): (f: (a: A) => Kind3) => (ta: Kind) => Kind3>; export declare function traverse(F: Applicative3C): (f: (a: A) => Kind3) => (ta: Kind) => Kind3>; export declare function traverse(F: Applicative2): (f: (a: A) => Kind2) => (ta: Kind) => Kind2>; export declare function traverse(F: Applicative2C): (f: (a: A) => Kind2) => (ta: Kind) => Kind2>; export declare function traverse(F: Applicative1): (f: (a: A) => Kind) => (ta: Kind) => Kind>; export declare function traverse(F: Applicative): (f: (a: A) => HKT) => (ta: Kind) => HKT>; /** * `sequence` takes a {@link Stream} where elements are {@link HKT} of `A` and * using an applicative of that {@link HKT}, returns an {@link HKT} of * {@link Stream}. * E.g. it can turn a `Stream>` into an * `Either>` * * `sequence` requires an `Applicative` of the {@link HKT} you are targeting, * e.g. to turn an `Stream>` into an `Either>`, it * needs an `Applicative` for `Either`, to turn a `Stream>` into an * `Option>` it needs an `Applicative` for `Option`. * * @export * @template F The category type. * @param {Applicative} F The applicative instance. * @return {(ta: Kind>) => HKT>} A function * that will take a stream of given `HKT` and will return that `HKT` containing * a stream of its type. * * @category traversing * @__PURE__ */ export declare function sequence(F: Applicative4): (ta: Kind>) => Kind4>; export declare function sequence(F: Applicative3): (ta: Kind>) => Kind3>; export declare function sequence(F: Applicative3C): (ta: Kind>) => Kind3>; export declare function sequence(F: Applicative2): (ta: Kind>) => Kind2>; export declare function sequence(F: Applicative2C): (ta: Kind>) => Kind2>; export declare function sequence(F: Applicative1): (ta: Kind>) => Kind>; export declare function sequence(F: Applicative): (ta: Kind>) => HKT>; /** * The `Traversable` category instance for {@link Stream}. * * @category traversing */ export declare const Traversable: Traversable1;