Channel151
Constructors
acquireReleaseconstAcquires a resource, emits the acquired value as a single channel element, and registers release in the channel scope.acquireUseReleaseconstAcquires a resource, uses it to build a Channel, and guarantees that release runs with the channel's Exit when the channel completes, fails, or is interrupted.callbackconstCreates a Channel that interacts with a callback function using a queue.callbackArrayconstCreates a Channel that interacts with a callback function using a queue, emitting arrays.dieconstConstructs a channel that fails immediately with the specified defect.drainconstCreates a new channel that consumes all output from the source channel but emits nothing, preserving only the completion value.emptyconstRepresents a Channel that emits no elements.endconstCreates a Channel that immediately ends with the specified value.endSyncconstCreates a Channel that immediately ends with the lazily evaluated value.failconstConstructs a channel that fails immediately with the specified error.failCauseconstConstructs a channel that fails immediately with the specified Cause.failCauseSyncconstConstructs a channel that fails immediately with the specified lazily evaluated Cause.failSyncconstConstructs a channel that fails immediately with the specified lazily evaluated error.flattenconstFlattens a channel of channels.fromArrayconstCreates a Channel that emits all elements from an array.fromAsyncIterableconstCreates a channel that pulls values from an AsyncIterable.fromAsyncIterableArrayconstCreates a channel from an AsyncIterable, emitting each yielded value as a single-element non-empty array.fromChunkconstCreates a Channel that emits all elements from a chunk.fromEffectconstUses an effect to write a single value to the channel.fromEffectDoneconstCreates a channel that evaluates an effect and uses its successful value as the channel's done value without emitting any output elements.fromEffectDrainconstUses an effect and discards its result.fromEffectTakeconstCreates a channel from an effect that produces a Take.fromIterableconstCreates a Channel that emits all elements from an iterable.fromIterableArrayconstCreates a Channel that emits arrays of elements from an iterable.fromIteratorconstCreates a Channel from an iterator.fromIteratorArrayconstCreates a Channel from an iterator that emits arrays of elements.fromPubSubconstCreates a channel from a PubSub that outputs individual values.fromPubSubArrayconstCreates a channel from a PubSub that outputs arrays of values.fromPubSubTakeconstSubscribes to a PubSub of Take values and exposes them as a channel.fromPullconstCreates a Channel from an Effect that produces a Pull.fromQueueconstCreates a channel from a queue.fromQueueArrayconstCreates a channel from a queue that emits arrays of elements.fromScheduleconstCreates a Channel from a Schedule.fromSubscriptionconstCreates a channel from a PubSub subscription.fromSubscriptionArrayconstCreates a channel from a PubSub subscription that outputs arrays of values.fromTransformconstCreates a Channel from a transformation function that operates on upstream pulls.fromTransformBracketconstCreates a Channel from a transformation function that operates on upstream pulls, but also provides a forked scope that closes when the resulting Channel completes.identityconstCreates a channel that forwards upstream input elements, input errors, and the upstream done value unchanged.neverconstRepresents a Channel that never completes.succeedconstCreates a Channel that emits a single value and then ends.suspendconstCreates a Channel that lazily evaluates to another channel.syncconstCreates a Channel that emits a single value computed by a lazy evaluation.transformPullconstTransforms a Channel by applying a function to its Pull implementation.unwrapconstConstructs a Channel from a scoped effect that will result in a Channel if successful.Services
contextWithconstCreates a channel from the specified services.provideconstProvides a Layer or Context to the channel, removing the corresponding service requirements.provideContextconstProvides a Context to the channel, removing the corresponding service requirements from the returned channel.provideServiceconstProvides a concrete service for a context key, removing that service requirement from the returned channel.provideServiceEffectconstProvides a service to the channel after obtaining it from an effect.updateContextconstTransforms the current context before running the channel.updateServiceconstUpdates a service in the current context before running the channel.Models
ChannelinterfaceA Channel is a nexus of I/O operations, which supports both reading and writing.ChannelUnifyinterfaceType-level unification support for Channel values.ChannelUnifyIgnoreinterfaceMarker used by Unify while resolving Channel values.HaltStrategytypeRepresents strategies for halting merged channels when one completes or fails.VarianceinterfacePhantom variance marker for the type parameters of Channel.VarianceStructinterfaceStructural encoding used by Variance to record each Channel type parameter's variance.Type Ids
Guards
Filtering
filterconstFilters the output elements of a channel using a predicate function.filterArrayconstFilters arrays of elements emitted by a channel, applying the filter to each element within the arrays and only emitting non-empty filtered arrays.filterArrayEffectconstFilters each element inside emitted non-empty arrays with an effectful predicate.filterEffectconstFilters output elements with an effectful predicate.filterMapconstFilters and maps output elements using a Filter.filterMapArrayconstFilters and maps each element inside emitted non-empty arrays using a Filter.filterMapArrayEffectconstFilters and maps each element inside emitted non-empty arrays using an effectful Filter.filterMapEffectconstFilters and maps output elements using an effectful Filter.Sequencing
combineconstCombines two channels with a stateful pull function.concatconstConcatenates this channel with another channel, so that the second channel starts emitting values after the first channel has completed.concatWithconstConcatenates this channel with another channel created from the terminal value of this channel.embedInputconstRuns an input handler against the upstream pull while the wrapped channel runs without receiving upstream input directly.flatMapconstMaps each output element to a channel and flattens the child channel outputs.mapconstMaps the output of this channel using the specified function.mapAccumconstMaps over a channel statefully with an accumulator, where each element can produce multiple output values.mapDoneconstMaps the done value of this channel using the specified function.mapDoneEffectconstMaps the done value of this channel using the specified effectful function.mapEffectconstMaps each output element with an effectful function, preserving the source channel's done value.mapInputconstReturns a new channel which is the same as this one but applies the given function to the input channel’s input elements.mapInputErrorconstReturns a new channel which is the same as this one but applies the given function to the input errors.orElseIfEmptyconstRuns a fallback channel if this channel completes without emitting any output elements.pipeToconstReturns a new channel that pipes the output of this channel into the specified channel.pipeToOrFailconstReturns a new channel that pipes the output of this channel into the specified channel and preserves this channel's failures without providing them to the other channel for observation.scanconstTransforms a channel statefully by scanning over its output with an accumulator function.scanEffectconstTransforms a channel statefully by scanning over its output with an effectful accumulator function.scheduleconstRuns a schedule step for each output element while preserving the emitted elements.switchMapconstMaps each output element to a channel and emits values from the most recent active child channels.tapconstApplies a side effect function to each output element of the channel, returning a new channel that emits the same elements.Destructors
runIntoPubSubconstRuns a channel and publishes each output element to a PubSub.runIntoPubSubArrayconstRuns an array-emitting channel and publishes each array element to a PubSub.runIntoQueueconstRuns a channel and offers each output element into a queue.runIntoQueueArrayconstRuns a channel that emits non-empty arrays and offers each array element into a queue.toPubSubconstConverts a channel to a PubSub for concurrent consumption.toPubSubArrayconstConverts an array-emitting channel to a scoped PubSub for concurrent consumption.toPubSubTakeconstConverts a channel to a scoped PubSub of Take values.toPullconstConverts a channel to a scoped Pull for low-level consumption.toPullScopedconstConverts a channel to a Pull within an existing scope.toQueueconstCreates a scoped queue and forks the channel to feed it for concurrent consumption.toQueueArrayconstCreates a scoped queue and forks an array-emitting channel to feed it.toTransformconstConverts a Channel back to its underlying transformation function.Buffering
bufferconstBuffers individual output elements in a queue with the configured capacity so a faster producer can progress independently of a slower consumer.bufferArrayconstBuffers array output elements in a queue with the configured capacity so a faster producer can progress independently of a slower consumer.Combining
Constants
Do Notation
Error Handling
catchCauseconstCatches any cause of failure from the channel and allows recovery by creating a new channel based on the caught cause.catchCauseFilterconstRecovers from channel failures whose full Cause is selected by a Filter.catchCauseIfconstCatches causes of failure that match a specific filter, allowing conditional error recovery based on the type of failure.catchFilterconstRecovers from typed channel errors selected by a Filter.catchIfconstRecovers from typed channel errors that match a predicate or refinement.catchReasonconstCatches a specific reason within a tagged error.catchReasonsconstCatches multiple reasons within a tagged error using an object of handlers.catchTagconstRecovers from tagged channel errors whose _tag matches one or more tags.ignoreconstIgnores all errors in the channel, converting them to an empty channel.ignoreCauseconstIgnores all errors in the channel including defects, converting them to an empty channel.mapErrorconstReturns a new channel, which is the same as this one, except the failure value of the returned channel is created by applying the specified function to the failure value of this channel.onErrorconstAttaches a finalizer that runs only when the channel exits with failure.orDieconstConverts all errors in the channel to defects (unrecoverable failures).retryconstReturns a new channel that retries this channel according to the specified schedule whenever it fails.tapCauseconstRuns an effect with the full failure Cause when the channel fails, then fails the returned channel with the original cause.tapErrorconstRuns an effect when the channel fails with a typed error, then preserves the original channel failure.unwrapReasonconstPromotes nested reason errors into the channel error, replacing the parent error.Execution
runCollectconstRuns a channel and collects all output elements into an array.runCountconstRuns a channel and counts the number of elements it outputs.runDoneconstRuns a channel and outputs the done value.runDrainconstRuns a channel and discards all output elements, returning only the final result.runFoldconstRuns a channel and folds over all output elements with an accumulator.runFoldEffectconstRuns a channel and effectfully folds all output elements with an accumulator.runForEachconstRuns a channel and applies an effect to each output element.runForEachWhileconstRuns a channel and applies an effectful predicate to each output element until the predicate returns false.runHeadconstRuns a channel until the first output element is available, returning it in an Option.runLastconstRuns a channel to completion and returns the last output element in an Option.Hooks
Interruption
Repetition
Resource Management
ensuringconstReturns a channel with a finalizer effect that is guaranteed to run once the channel begins execution, whether it succeeds or fails.onExitconstReturns a channel with an exit-aware finalizer that is guaranteed to run once the channel begins execution, whether it succeeds or fails.scopedconstRuns a channel with a scope provided for the duration of the channel execution, removing the channel's Scope requirement.