import { Just } from './Just' ; import { Maybe } from './Maybe' ; import { Nothing } from './Nothing' ; import { curry2 } from '@typed/functions' ; import { fromJust } from './fromJust' ; import { isNothing } from './isNothing' ; name export const combineArray = curry2 ( __combineArray ) as CombineArray ; function __combineArray < R > ( f , maybes ) { const containsNothing = maybes . some ( isNothing ) ; return containsNothing ? Nothing : Just . of < R > ( f ( ... ( maybes as ReadonlyArray < Just < any > > ) . map ( fromJust ) ) ) ; } export type CombineArray = { < A , B , C > ( f , maybes ) : Maybe < C > ; < A , B , C , D > ( f , maybes ) : Maybe < D > ; < A , B , C , D , E > ( f , maybes ) : Maybe < E > ; < A , B , C , D , E , F > ( f , maybes ) : Maybe < F > ; < A , B , C , D , E , F , G > ( f , maybes ) : Maybe < G > ; < A , B , C > ( f ) : ( maybes : [ Maybe < A > , Maybe < B > ] ) => Maybe < C > ; < A , B , C , D > ( f ) : ( maybes : [ Maybe < A > , Maybe < B > , Maybe < C > ] ) => Maybe < D > ; < A , B , C , D , E > ( f ) : ( maybes : [ Maybe < A > , Maybe < B > , Maybe < C > , Maybe < D > ] ) => Maybe < E > ; < A , B , C , D , E , F > ( f ) : ( maybes : [ Maybe < A > , Maybe < B > , Maybe < C > , Maybe < D > , Maybe < E > ] ) => Maybe < F > ; < A , B , C , D , E , F , G > ( f ) : ( maybes : [ Maybe < A > , Maybe < B > , Maybe < C > , Maybe < D > , Maybe < E > , Maybe < F > ] ) => Maybe < G > ; ( f ) : { < A , B > ( maybes ) : Maybe < [ A , B ] > ; < A , B , C > ( maybes ) : Maybe < [ A , B , C ] > ; < A , B , C , D > ( maybes ) : Maybe < [ A , B , C , D ] > ; < A , B , C , D , E > ( maybes ) : Maybe < [ A , B , C , D , E ] > ; < A , B , C , D , E , F > ( maybes ) : Maybe < [ A , B , C , D , E , F ] > ; } ; < R > ( f , maybes ) : Maybe < R > ; < R > ( f ) : ( maybes : ReadonlyArray < Maybe < any > > ) => Maybe < R > ; } ;