import { Either, isLeft } from './Either' import { curry } from '@typed/lambda' import { fromLeft } from './Left' /** * Returns a `Either` that is the result of calling `f` with the rejected * value of another `Either`. * @name chainLeft(f: (value: B) => Either, either: Either): Either */ export const chainLeft = curry(__chainLeft) as { (f: (value: A) => Either, either: Either): Either (f: (value: A) => Either): (either: Either) => Either } function __chainLeft(f: (value: A) => Either, either: Either): Either { return isLeft(either) ? f(fromLeft(either)) : either }