| 33 | export const isNonFailure = <E, A>(self: These<E, A>): self is These<never, A> => E.isRight(self.either) |
| 34 | |
| 35 | export function foldM_<E, A, E1, A1, E2, A2, E3, A3>( |
| 36 | self: These<E, A>, |
| 37 | onSuccess: (a: A) => These<E1, A1>, |
| 38 | onBoth: (a: A, e: E) => These<E2, A2>, |
| 39 | onFail: (e: E) => These<E3, A3>, |
| 40 | ): These<E1 | E2 | E3, A1 | A2 | A3> { |
| 41 | return new These( |
| 42 | E.fold_( |
| 43 | self.either, |
| 44 | (x): E.Either<E1 | E2 | E3, Tp.Tuple<[A1 | A2 | A3, O.Option<E1 | E2 | E3>]>> => onFail(x).either, |
| 45 | ({ tuple: [result, warnings] }) => |
| 46 | warnings._tag === 'None' ? onSuccess(result).either : onBoth(result, warnings.value).either, |
| 47 | ), |
| 48 | ) |
| 49 | } |
| 50 | |
| 51 | export function foldM<E, A, E1, A1, E2, A2, E3, A3>( |
| 52 | onSuccess: (a: A) => These<E1, A1>, |