import { Mapper } from '../Mapper' import { success } from './constructors' import { Result } from './index' export const reduceOverMonad = (mappers: Mapper>[]) => (result: Result) => { return mappers.reduce((result, mapper) => { switch (result.success) { case false: return result case true: return mapper(result.data) } }, result) } export const reduceOverMonadW = (mappers: Mapper>[]) => (data: Data) => reduceOverMonad(mappers)(success(data)) export const andThen = (result: Result) => (mapper: Mapper) => { if (result.success) { return success(mapper(result.data)) } else { return result } } // export function withResults(promises: [Promise, Promise, Promise, Promise, Promise

, Promise, Promise, Promise, Promise, Promise, Promise, Promise]): Promise<[A, M, K, N, P, D, G, C, O, L, Q, R]>; // // export function withResults(promises: [Promise, Promise, Promise, Promise, Promise

, Promise, Promise, Promise, Promise, Promise, Promise]): Promise<[A, M, K, N, P, D, G, C, O, L, Q]>; // // export function withResults(promises: [Promise, Promise, Promise, Promise, Promise

, Promise, Promise, Promise, Promise, Promise]): Promise<[A, M, K, N, P, D, G, C, O, L]>; // // export function withResults(promises: [Promise, Promise, Promise, Promise, Promise

, Promise, Promise, Promise, Promise]): Promise<[A, M, K, N, P, D, G, C, O]>; // // export function withResults(promises: [Promise, Promise, Promise, Promise, Promise

, Promise, Promise, Promise]): Promise<[A, M, K, N, P, D, G, C]>; // // export function withResults(promises: [Promise, Promise, Promise, Promise, Promise

, Promise, Promise]): Promise<[A, M, K, N, P, D, G]>; // // export function withResults(promises: [Promise, Promise, Promise, Promise, Promise

, Promise]): Promise<[A, M, K, N, P, D]>; // // export function withResults(promises: [Promise, Promise, Promise, Promise, Promise

]): Promise<[A, M, K, N, P]>; // // export function withResults(promises: [Promise, Promise, Promise, Promise]): Promise<[A, M, K, N]>; // // export function withResults(promises: [Promise, Promise, Promise]): Promise<[A, M, K]>; // export const withResults = (results: [Result, Result]) => { // const values: [Data1, Data2] = [] // for (const result of results) { // if (result.success) { // // } // } // const resultWithError = results.find(r => !r.success) // if (resultWithError) return resultWithError // const values = results.map(r => r.data) // } // export const withResults = (results: Result[]) => { // // } function concat(t: [...T], u: [...U]): [...T, ...U] { return [...t, ...u] }