Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
5007132
add comprehensive Queue/TxQueue API alignment plan
mikearnaldi Oct 7, 2025
0848096
docs(PLAN): add detailed implementation steps with commit messages
mikearnaldi Oct 7, 2025
c3355cd
docs(PLAN): add critical implementation rules and validation requirem…
mikearnaldi Oct 7, 2025
4687522
feat(Cause): add Done error type for queue completion
mikearnaldi Oct 7, 2025
9f59aa5
refactor(Queue): migrate to Cause.Done for completion
mikearnaldi Oct 7, 2025
8ecf0d3
refactor(TxQueue): migrate from NoSuchElementError to Cause.Done
mikearnaldi Oct 7, 2025
c017ac8
feat(Queue): add interrupt operation for graceful close
mikearnaldi Oct 7, 2025
e8068d0
refactor(TxQueue): change clear() to return Array<A> instead of void
mikearnaldi Oct 7, 2025
341b524
feat(Queue): add Enqueue interface for interface segregation
mikearnaldi Oct 7, 2025
148069e
refactor(TxQueue): change takeAll() to return NonEmptyArray<A>
mikearnaldi Oct 7, 2025
46e8ff4
refactor(TxQueue): change offerAll() to return Array<A> instead of Ch…
mikearnaldi Oct 7, 2025
7a7bf53
feat(Queue): add poll() operation for non-blocking take
mikearnaldi Oct 7, 2025
76f33f5
feat(Queue): add peek() operation to view items without removing
mikearnaldi Oct 7, 2025
1c56f1e
fix(TxQueue): prevent linter from converting Cause/Arr to type imports
mikearnaldi Oct 7, 2025
fabda05
refactor(Queue): implement end() in terms of failCause like TxQueue
mikearnaldi Oct 7, 2025
228fbe6
feat(Queue): add failCauseUnsafe and make failCause dual
mikearnaldi Oct 7, 2025
108fb9e
refactor(Queue): remove done/doneUnsafe, use failCause/failCauseUnsafe
mikearnaldi Oct 7, 2025
1b84399
chore: remove PLAN.md after completion
mikearnaldi Oct 7, 2025
df1e1c5
refactor(Queue): migrate Queue.Done references to Cause.Done
mikearnaldi Oct 7, 2025
9659391
fix(TxQueue): align clear implementation with Queue for halt cause ha…
mikearnaldi Oct 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions packages/effect/src/Cause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import type { Pipeable } from "./interfaces/Pipeable.ts"
import * as core from "./internal/core.ts"
import * as effect from "./internal/effect.ts"
import * as ServiceMap from "./ServiceMap.ts"
import type * as Pull from "./stream/Pull.ts"
import type { Span } from "./Tracer.ts"
import type { NoInfer } from "./types/Types.ts"

Expand Down Expand Up @@ -692,6 +693,79 @@ export interface NoSuchElementError extends YieldableError {
*/
export const NoSuchElementError: new(message?: string) => NoSuchElementError = core.NoSuchElementError

/**
* Tests if a value is a `Done` error.
*
* @example
* ```ts
* import { Cause } from "effect"
*
* console.log(Cause.isDone(Cause.Done)) // true
* console.log(Cause.isDone("not an error")) // false
* ```
*
* @category guards
* @since 4.0.0
*/
export const isDone: (u: unknown) => u is Done = core.isDone

/**
* @since 4.0.0
* @category errors
*/
export const DoneTypeId: "~effect/Cause/Done" = core.DoneTypeId

/**
* Represents a graceful completion signal for queues and streams.
*
* `Done` is used to signal that a queue or stream has completed normally
* and no more elements will be produced. This is distinct from an error
* or interruption - it represents successful completion.
*
* @example
* ```ts
* import { Cause, Effect } from "effect"
* import { Queue } from "effect"
*
* const program = Effect.gen(function*() {
* const queue = yield* Queue.bounded<number, Cause.Done>(10)
*
* yield* Queue.offer(queue, 1)
* yield* Queue.offer(queue, 2)
*
* // Signal completion
* yield* Queue.end(queue)
*
* // Taking from ended queue fails with Done
* const result = yield* Effect.flip(Queue.take(queue))
* console.log(Cause.isDone(result)) // true
* })
* ```
*
* @since 4.0.0
* @category errors
*/
export interface Done extends Pull.Halt<void>, YieldableError {
readonly [DoneTypeId]: typeof DoneTypeId
readonly _tag: "Done"
}

/**
* Singleton instance of `Done` error to signal graceful completion.
*
* @example
* ```ts
* import { Cause } from "effect"
*
* console.log(Cause.Done._tag) // "Done"
* console.log(Cause.isDone(Cause.Done)) // true
* ```
*
* @category constructors
* @since 4.0.0
*/
export const Done: Done = core.Done

/**
* @category errors
* @since 4.0.0
Expand Down
Loading
Loading