Follow one execution
Emits typed failures as values and fails with the first successful value.
flipTick 0. Failure: start; Success: start.
Read this diagram
Follow each lane from left to right. Events stacked vertically share a tick; the green cursor marks the current time across every lane.
- A value
The text inside the pill is the emitted value. - Work starts
The raised chevron starts an inner run (^in the source). - The run returns
The vertical bar ends this lane’s run. - A cause is delivered
The exclamation mark belongs to this lane. - Work is interrupted
The cross marks cancellation of this run. - Current time
The line and diamond move together across all lanes. - Happening now
A highlighted event is at the current tick. - Still ahead
Muted, dashed values have not happened yet. - Time continues
The lane’s arrow is not a return marker. An empty stretch can be quiet work that is still running.
Illustrated ticks start at 0. At 1×, one illustrated tick takes one second; captions specify real durations when timing matters. A cause or interruption belongs to its lane, and other work may continue. Scroll horizontally to inspect the rest of a long timeline.
If a source Cause contains any Fail, the first typed error e is delivered as success and the entire Cause is discarded, including defects or interrupts composed beside that Fail. A Cause with no Fail propagates unchanged. A source success a terminates the returned Fx with typed failure a. The source subscription is the only lifetime and external interruption still stops it.
Import
import { flip } from "@typed/fx/Fx";Signatures
export declare const flip: <A, E, R>(fx: Fx<A, E, R>) => Fx<E, A, R>;Why
Channel inversion makes an error-producing computation composable through
success operators, mirroring Effect’s flip without erasing either type.
Ownership and lifetime
If a source Cause contains any Fail, the first typed error e is delivered
as success and the entire Cause is discarded, including defects or interrupts
composed beside that Fail. A Cause with no Fail propagates unchanged. A source
success a terminates the returned Fx with typed failure a. The source
subscription is the only lifetime and external interruption still stops it.
Examples
import { flip } from "@typed/fx/Fx"
import { fail } from "@typed/fx/Fx"
const errorsAsValues = flip(fail("offline"))The first Fail wins over the rest of a composite Cause
```ts
import { Cause } from "effect"
import { flip } from "@typed/fx/Fx"
import { failCause } from "@typed/fx/Fx"
const composite = Cause.combine(Cause.fail("offline"), Cause.die("decoder defect"))
const errorValue = flip(failCause(composite))
```Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.