Hyperlinkv0.8.0-beta.28

Effect

Effect.flipconsteffect/Effect.ts:2463
<A, E, R>(self: Effect<A, E, R>): Effect<E, A, R>

Swaps an effect's success and failure channels.

When to use

Use to swap an Effect's success and failure channels.

Details

For an Effect<A, E, R>, the returned effect has type Effect<E, A, R>.

Example (Swapping success and failure channels)

import { Effect } from "effect"

//      ┌─── Effect<number, string, never>
//      ▼
const program = Effect.fail("Oh uh!").pipe(Effect.as(2))

//      ┌─── Effect<string, number, never>
//      ▼
const flipped = Effect.flip(program)
mapping
Source effect/Effect.ts:24631 lines
export const flip: <A, E, R>(self: Effect<A, E, R>) => Effect<E, A, R> = internal.flip