UNPKG

effect-ts-folds

Version:
23 lines 872 B
import { Either as EI, flow, Tuple } from 'effect'; /** * Run a pair of functions on the same value and return the result tuple. * @category pair */ export const fanout = (ab, ac) => (a) => [ab(a), ac(a)]; /** * Convert a pair of functions into a function that runs the first on left and * the second on right. * @category pair */ export const fanin = (ba, ca) => EI.match({ onLeft: ba, onRight: ca }); /** * Map over both members of a pair with a single function. * @category pair */ export const pairMap = (ab) => ([a1, a2]) => [ab(a1), ab(a2)]; export const pairWithFirst = (first) => (second) => [first, second]; export const pairWithSecond = (second) => (first) => [first, second]; export const square = (a) => [a, a]; export const squareMapFirst = f => flow(square, Tuple.mapFirst(f)); export const pair = (a, b) => [a, b]; //# sourceMappingURL=Pair.js.map