import { flow } from "../Function"; import { fail, succeed } from "./constructors"; import { foldM_ } from "./fold"; import type { Async } from "./model"; /* * ------------------------------------------- * Bifunctor Async * ------------------------------------------- */ export const first_ = (pab: Async, f: (e: E) => B): Async => foldM_(pab, flow(f, fail), succeed); export const first = (f: (e: E) => B) => (pab: Async): Async => first_(pab, f); export const bimap_ = (pab: Async, f: (e: E) => B, g: (a: A) => C): Async => foldM_(pab, flow(f, fail), flow(g, succeed)); export const bimap = (f: (e: E) => B, g: (a: A) => C) => (pab: Async): Async => bimap_(pab, f, g);