Skip to content
Effect Days 2026 Get your ticket

Take

23 exports Added in v2.0.0 Source

Constructors

chunk

Added in v2.0.0 Source

Creates a Take with the specified chunk.

Signature

declare const chunk: <A>(chunk: Chunk.Chunk<A>) => Take<A>

die

Added in v2.0.0 Source

Creates a failing Take with the specified defect.

Signature

declare const die: (defect: unknown) => Take<never>

dieMessage

Added in v2.0.0 Source

Creates a failing Take with the specified error message.

Signature

declare const dieMessage: (message: string) => Take<never>

end

Added in v2.0.0 Source

Represents the end-of-stream marker.

Signature

declare const end: Take<never>

fail

Added in v2.0.0 Source

Creates a failing Take with the specified error.

Signature

declare const fail: <E>(error: E) => Take<never, E>

failCause

Added in v2.0.0 Source

Creates a failing Take with the specified cause.

Signature

declare const failCause: <E>(cause: Cause.Cause<E>) => Take<never, E>

fromEffect

Added in v2.0.0 Source

Creates an effect from Effect<A, E, R> that does not fail, but succeeds with the Take<A, E>. Error from stream when pulling is converted to Take.failCause. Creates a single value chunk.

Signature

declare const fromEffect: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<Take<A, E>, never, R>

fromExit

Added in v2.0.0 Source

Creates a Take from an Exit.

Signature

declare const fromExit: <A, E>(exit: Exit.Exit<A, E>) => Take<A, E>

fromPull

Added in v2.0.0 Source

Creates effect from Effect<Chunk<A>, Option<E>, R> that does not fail, but succeeds with the Take<A, E>. Errors from stream when pulling are converted to Take.failCause, and the end-of-stream is converted to Take.end.

Signature

declare const fromPull: <A, E, R>(pull: Effect.Effect<Chunk.Chunk<A>, Option.Option<E>, R>) => Effect.Effect<Take<A, E>, never, R>

make

Added in v2.0.0 Source

Constructs a Take.

Signature

declare const make: <A, E>(exit: Exit.Exit<Chunk.Chunk<A>, Option.Option<E>>) => Take<A, E>

of

Added in v2.0.0 Source

Creates a Take with a single value chunk.

Signature

declare const of: <A>(value: A) => Take<A>

Destructors

done

Added in v2.0.0 Source

Transforms a Take<A, E> to an Effect<A, E>.

Signature

declare const done: <A, E>(self: Take<A, E>) => Effect.Effect<Chunk.Chunk<A>, Option.Option<E>>

match

Added in v2.0.0 Source

Folds over the failure cause, success value and end-of-stream marker to yield a value.

Signature

declare const match: {
<Z, E, Z2, A, Z3>(options: {
readonly onEnd: () => Z;
readonly onFailure: (cause: Cause.Cause<E>) => Z2;
readonly onSuccess: (chunk: Chunk.Chunk<A>) => Z3;
}): (self: Take<A, E>) => Z | Z2 | Z3;
<A, E, Z, Z2, Z3>(self: Take<A, E>, options: {
readonly onEnd: () => Z;
readonly onFailure: (cause: Cause.Cause<E>) => Z2;
readonly onSuccess: (chunk: Chunk.Chunk<A>) => Z3;
}): Z | Z2 | Z3;
}

matchEffect

Added in v2.0.0 Source

Effectful version of Take.fold.

Folds over the failure cause, success value and end-of-stream marker to yield an effect.

Signature

declare const matchEffect: {
<Z, E2, R, E, Z2, R2, A, Z3, E3, R3>(options: {
readonly onEnd: Effect.Effect<Z, E2, R>;
readonly onFailure: (cause: Cause.Cause<E>) => Effect.Effect<Z2, E2, R2>;
readonly onSuccess: (chunk: Chunk.Chunk<A>) => Effect.Effect<Z3, E3, R3>;
}): (self: Take<A, E>) => Effect<Z | Z2 | Z3, E2 | E | E3, R | R2 | R3>;
<A, E, Z, E2, R, Z2, R2, Z3, E3, R3>(self: Take<A, E>, options: {
readonly onEnd: Effect.Effect<Z, E2, R>;
readonly onFailure: (cause: Cause.Cause<E>) => Effect.Effect<Z2, E2, R2>;
readonly onSuccess: (chunk: Chunk.Chunk<A>) => Effect.Effect<Z3, E3, R3>;
}): Effect<Z | Z2 | Z3, E | E2 | E3, R | R2 | R3>;
}

Getters

isDone

Added in v2.0.0 Source

Checks if this take is done (Take.end).

Signature

declare const isDone: <A, E>(self: Take<A, E>) => boolean

isFailure

Added in v2.0.0 Source

Checks if this take is a failure.

Signature

declare const isFailure: <A, E>(self: Take<A, E>) => boolean

isSuccess

Added in v2.0.0 Source

Checks if this take is a success.

Signature

declare const isSuccess: <A, E>(self: Take<A, E>) => boolean

Mapping

map

Added in v2.0.0 Source

Transforms Take<A, E> to Take<B, A> by applying function f.

Signature

declare const map: {
<A, B>(f: (a: A) => B): <E>(self: Take<A, E>) => Take<B, E>;
<A, E, B>(self: Take<A, E>, f: (a: A) => B): Take<B, E>;
}

Models

Take interface

Added in v2.0.0 Source

A Take<A, E> represents a single take from a queue modeling a stream of values. A Take may be a failure cause Cause<E>, a chunk value Chunk<A>, or an end-of-stream marker.

Signature

interface Take<out A, out E = never> extends Variance<A, E>, Pipeable {}

Other

Take

Added in v2.0.0 Source

Sequencing

tap

Added in v2.0.0 Source

Returns an effect that effectfully "peeks" at the success of this take.

Signature

declare const tap: {
<A, X, E2, R>(f: (chunk: Chunk<A>) => Effect<X, E2, R>): <E>(self: Take<A, E>) => Effect<void, E2 | E, R>;
<A, E, X, E2, R>(self: Take<A, E>, f: (chunk: Chunk<A>) => Effect<X, E2, R>): Effect<void, E | E2, R>;
}

Symbols

TakeTypeId

Added in v2.0.0 Source

Signature

declare const TakeTypeId: unique symbol

TakeTypeId type

Added in v2.0.0 Source

Signature

type TakeTypeId = typeof TakeTypeId