Package: effect
Module: Result
Swaps the success and failure channels of a Result.
When to use
Use to swap channels when failure-focused operations are easier through success-oriented combinators.
Details
Success<A> becomes Failure<A> (i.e., Result<E, A>)Failure<E> becomes Success<E> (i.e., Result<E, A>)map)
to the error channel, then flip backExample (Swapping channels)
import { Result } from "effect"
console.log(Result.flip(Result.succeed(42)))
// Output: { _tag: "Failure", failure: 42, ... }
console.log(Result.flip(Result.fail("error")))
// Output: { _tag: "Success", success: "error", ... }
See
mapError to transform the error without swappingSignature
declare const flip: <A, E>(self: Result<A, E>) => Result<E, A>
Since v2.0.0