<E>(failure: Cause.Reason<E>): failure is Cause.Fail<E & Cause.Done<any>>Checks whether a Cause.Reason is a Fail reason whose error is a
Cause.Done signal.
When to use
Use when you need to identify done completion reasons while traversing
cause.reasons, before handling ordinary failures.
export const const isDoneFailure: <E>(
failure: Cause.Reason<E>
) => failure is Cause.Fail<E & Cause.Done<any>>
Checks whether a Cause.Reason is a Fail reason whose error is a
Cause.Done signal.
When to use
Use when you need to identify done completion reasons while traversing
cause.reasons, before handling ordinary failures.
isDoneFailure = <function (type parameter) E in <E>(failure: Cause.Reason<E>): failure is Cause.Fail<E & Cause.Done<any>>E>(
failure: Cause.Reason<E>failure: import CauseCause.type Reason<E> = Cause.Fail<E> | Cause.Die | Cause.InterruptA single entry inside a Cause's reasons array.
Details
Narrow to a concrete type with
isFailReason
,
isDieReason
,
or
isInterruptReason
.
Fail<E> — typed error, access via .error
Die — untyped defect, access via .defect
Interrupt — fiber interruption, access via .fiberId
Every reason carries an annotations map and an annotate method for
attaching tracing metadata.
Example (Narrowing a reason)
import { Cause } from "effect"
const reason = Cause.fail("error").reasons[0]
if (Cause.isFailReason(reason)) {
console.log(reason.error) // "error"
}
Companion namespace for the Reason type.
Reason<function (type parameter) E in <E>(failure: Cause.Reason<E>): failure is Cause.Fail<E & Cause.Done<any>>E>
): failure: Cause.Reason<E>failure is import CauseCause.interface Fail<out E>A typed, expected error produced by Effect.fail.
When to use
Use when inspecting Cause reasons that represent expected failures from the
typed error channel.
Details
The error property carries the typed value E. Use
isFailReason
to narrow a Reason to this type.
Example (Accessing the error)
import { Cause } from "effect"
const cause = Cause.fail("Something went wrong")
const reason = cause.reasons[0]
if (Cause.isFailReason(reason)) {
console.log(reason.error) // "Something went wrong"
}
Fail<function (type parameter) E in <E>(failure: Cause.Reason<E>): failure is Cause.Fail<E & Cause.Done<any>>E & import CauseCause.interface Done<A = void>A graceful completion signal for queues and streams.
When to use
Use to model normal producer completion through a stream or queue error
channel.
Details
Done indicates that a producer has finished normally — no more elements
will arrive. It is distinct from an error or interruption; it represents
successful completion. The optional value field can carry a final
leftover payload.
Example (Signaling queue completion)
import { Cause, Effect, Queue } from "effect"
const program = Effect.gen(function*() {
const queue = yield* Queue.bounded<number, Cause.Done>(10)
yield* Queue.offer(queue, 1)
yield* Queue.end(queue)
const result = yield* Effect.flip(Queue.take(queue))
console.log(Cause.isDone(result)) // true
})
Companion namespace for the Done interface.
Creates a Done signal with an optional value.
When to use
Use when you need to construct a low-level pull completion signal directly.
Done<any>> => failure: Cause.Reason<E>failure.Cause<out E>.ReasonProto<Tag extends string>._tag: "Fail" | "Die" | "Interrupt"_tag === "Fail" && import CauseCause.const isDone: (
u: unknown
) => u is Done<any>
Checks whether an arbitrary value is a Done signal.
Example (Checking the runtime type)
import { Cause } from "effect"
console.log(Cause.isDone(Cause.Done())) // true
console.log(Cause.isDone("not done")) // false
isDone(failure: Cause.Reason<E>(parameter) failure: {
error: E;
_tag: Tag;
annotations: ReadonlyMap<string, unknown>;
annotate: (annotations: Context.Context<never> | ReadonlyMap<string, unknown>, options?: { readonly overwrite?: boolean | undefined }) => Fail<E>;
toString: () => string;
toJSON: () => unknown;
}
failure.Fail<E>.error: Eerror)