import { curry } from '@typed/lambda' import { combineArray } from './combineArray' import { Maybe } from './Maybe' /** * Applies a function with the values contained in 2 `Maybes` if both are * `Just`s. If either `Maybe`s are `Nothing` then `Nothing` is returned. * @name combine(f: (a: A, b: B) => C, a: Maybe, b: Maybe): Maybe */ export const combine = curry(__combine) as { (f: (valueA: A, valueB: B) => C, maybeA: Maybe, maybeB: Maybe): Maybe (f: (valueA: A, valueB: B) => C, maybeA: Maybe): (maybeB: Maybe) => Maybe (f: (valueA: A, valueB: B) => C): { (maybeA: Maybe, maybeB: Maybe): Maybe (maybeA: Maybe): (maybeB: Maybe) => Maybe } } function __combine( f: (valueA: A, valueB: B) => C, maybeA: Maybe, maybeB: Maybe, ): Maybe { return combineArray(f, [maybeA, maybeB]) }