import * as AsyncValues from '../async/AsyncValues'; import * as Arr from './Arr'; import { Future } from './Future'; export const par = (futures: ArrayLike>): Future> => AsyncValues.par, T, Future>>(futures, Future.nu); export const traverse = (array: ArrayLike, fn: (value: A) => Future): Future => par(Arr.map(array, fn)); /** Deprecated for rename to traverse */ export const mapM = traverse; /** Kleisli composition of two functions: a -> Future b. * Note the order of arguments: g is invoked first, then the result passed to f. * This is in line with f . g = \x -> f (g a) * * compose :: ((b -> Future c), (a -> Future b)) -> a -> Future c */ export const compose = (f: (b: B) => Future, g: (a: A) => Future) => (a: A): Future => g(a).bind(f);