Effect235
Constructors
callbackconstCreates an Effect from a callback-based asynchronous API.dieconstCreates an effect that terminates a fiber with a specified error.failconstCreates an Effect that represents a recoverable error.failCauseconstCreates an Effect that represents a failure with a specific Cause.failCauseSyncconstCreates an Effect that represents a failure with a Cause computed lazily.failSyncconstCreates an Effect that represents a recoverable error using a lazy evaluation.gennamespaceProvides a way to write effectful code using generator functions, simplifying control flow and error handling.neverconstReturns an effect that will never produce anything.promiseconstCreates an Effect that represents an asynchronous computation guaranteed to succeed.succeedconstCreates an Effect that always succeeds with a given value.succeedNoneconstReturns an effect which succeeds with None.succeedSomeconstReturns an effect which succeeds with the value wrapped in a Some.suspendconstCreates an Effect lazily, delaying construction until it is needed.syncconstCreates an Effect that represents a synchronous side-effectful computation.tryPromiseconstCreates an Effect from an asynchronous computation that may throw or reject, mapping failures into the error channel.withFiberconstProvides access to the current fiber within an effect computation.yieldNowconstYields control back to the Effect runtime, allowing other fibers to execute.yieldNowWithconstYields control back to the Effect runtime with a specified priority, allowing other fibers to execute.Models
EffectinterfaceThe Effect interface defines a value that lazily describes a workflow or job.EffectIteratorinterfaceIterator interface for Effect generators, enabling Effect values to work with generator functions.EffectUnifyinterfaceType-level unification support for Effect values.ErrortypeExtracts the error type from an Effect.ServicestypeExtracts the required services type from an Effect.SuccesstypeExtracts the success type from an Effect.VarianceinterfaceVariance interface for Effect, encoding the type parameters' variance.Type Ids
Guards
Mapping
asconstReplaces the value inside an effect with a constant value.asSomeconstMaps the success value of an Effect to Some, preserving failures.asVoidconstMaps the success value of an Effect to void, preserving failures.flipconstSwaps an effect's success and failure channels.mapconstTransforms the value inside an effect by applying a function to it.mapBothconstApplies transformations to both the success and error channels of an effect.Filtering
filterconstFilters elements of an iterable using a predicate, refinement, or effectful predicate.filterMapconstFilters and maps elements of an iterable with a Filter.filterMapEffectconstFilters and maps elements of an iterable effectfully with a FilterEffect.filterMapOrElseconstFilters an effect with a Filter, providing an alternative effect on failure.filterMapOrFailconstFilters and maps an effect with a Filter, failing when the filter fails.filterOrElseconstFilters an effect, providing an alternative effect if the predicate fails.filterOrFailconstFilters an effect, failing with a custom error if the predicate fails.Sequencing
andThenconstRuns this effect and then runs another effect, optionally using the first effect's success value to choose the next effect.flatMapconstChains effects to produce new Effect instances, useful for combining operations that depend on previous results.flattenconstFlattens an Effect that produces another Effect into a single effect.tapconstRuns a side effect with the result of an effect without changing the original value.tapCauseconstRuns an effectful operation with the full Cause when the source effect fails.tapCauseFilterconstExecutes a side effect conditionally when a failed effect's cause passes a filter.tapCauseIfconstExecutes a side effect conditionally when a failed effect's cause matches a predicate.tapDefectconstRuns an effectful operation when the source effect dies with a defect.tapErrorconstRuns an effectful operation when the source effect fails, while preserving the original failure when the operation succeeds.tapErrorTagconstRuns an effectful handler when a failure's _tag matches.Context
provideServiceconstProvides one concrete service implementation to an effect.provideServiceEffectconstProvides one service to an effect using an effectful acquisition.serviceconstAccesses a service from the context.serviceOptionconstOptionally accesses a service from the environment.updateContextconstProvides part of the required context while leaving the rest unchanged.updateServiceconstRuns an effect with a service implementation transformed by the provided function.Logging
annotateLogsconstAdds an annotation to each log line in this effect.annotateLogsScopedconstAdds log annotations to the current scope.logconstLogs one or more messages using the default log level.logDebugconstLogs one or more messages at the DEBUG level.logErrorconstLogs one or more messages at the ERROR level.logFatalconstLogs one or more messages at the FATAL level.logInfoconstLogs one or more messages at the INFO level.logTraceconstLogs one or more messages at the TRACE level.logWarningconstLogs one or more messages at the WARNING level.logWithLevelconstCreates a logger function that logs at the specified level.withLoggerconstAdds a logger to the set of loggers which will output logs for this effect.withLogSpanconstAdds a span to each log line in this effect.Caching
cachedconstReturns an effect that lazily computes a result and caches it for subsequent evaluations.cachedInvalidateWithTTLconstCreates a cached effect result for a specified duration and allows manual invalidation before expiration.cachedWithTTLconstReturns an effect that caches its result for a specified Duration, known as "timeToLive" (TTL).Clock
Collecting
allconstCombines an iterable or record of effects into one effect whose success shape follows the input.findFirstconstReturns the first element that satisfies an effectful predicate.findFirstFilterconstReturns the first value that passes an effectful FilterEffect.forEachconstExecutes an effectful operation for each element in an Iterable.partitionconstApplies an effectful function to each element and partitions failures and successes.replicateconstReturns an array of n identical effects.replicateEffectconstPerforms this effect n times and collects results with Effect.all semantics.whileLoopconstExecutes a body effect repeatedly while a condition holds true.Condition Checking
Conditional Operators
Converting
fromNullishOrconstConverts a nullable value to an Effect, failing with a NoSuchElementError when the value is null or undefined.fromOptionconstConverts an Option into an Effect.fromResultconstConverts a Result to an Effect.transposeOptionconstConverts an Option of an Effect into an Effect of an Option.Converting Failures To Defects
Delays & Timeouts
delayconstReturns an effect that is delayed from this effect by the specified Duration.sleepconstReturns an effect that suspends the current fiber for the specified duration without blocking a JavaScript thread.timedconstReturns the runtime duration of an effect together with its result.timeoutconstAdds a time limit to an effect, triggering a timeout if the effect exceeds the duration.timeoutOptionconstRuns an effect with a time limit and represents only the timeout case as Option.none.timeoutOrElseconstApplies a timeout to an effect, with a fallback effect executed if the timeout is reached.Do Notation
Eager
catchEagerconstApplies catch eagerly when an effect is already resolved.flatMapEagerconstApplies flatMap eagerly when an effect is already resolved.fnUntracedEagerconstCreates untraced function effects with eager evaluation optimization.mapBothEagerconstApplies mapBoth eagerly when an effect is already resolved.mapEagerconstApplies map eagerly when an effect is already resolved.mapErrorEagerconstApplies mapError eagerly when an effect is already resolved.Effectify
Environment
contextconstReturns the complete context.contextWithconstTransforms the current context using the provided function.provideconstProvides dependencies to an effect using layers or a context.provideContextconstProvides a context to an effect, fulfilling its service requirements.setContextconstRuns an effect with the provided context as its complete environment.Error Accumulation
Error Handling
catchCauseconstHandles both recoverable and unrecoverable errors by providing a recovery effect.catchCauseFilterconstRecovers from specific failures based on a Filter.catchCauseIfconstRecovers from specific failures based on a predicate.catchDefectconstRecovers from defects using a provided recovery function.catchFilterconstRecovers from specific errors using a Filter.catchIfconstRecovers from specific errors using a Predicate or Refinement.catchNoSuchElementconstCatches NoSuchElementError failures and converts them to Option.none.catchReasonconstCatches a specific reason within a tagged error.catchReasonsconstCatches multiple reasons within a tagged error using an object of handlers.catchTagconstCatches and handles specific errors by their _tag field, which is used as a discriminator.catchTagsconstHandles multiple errors in a single block of code using their _tag field.ignoreconstDiscards both the success and failure values of an effect.ignoreCauseconstIgnores the effect's failure cause, including defects and interruptions.mapErrorconstTransforms the failure value of an effect without changing its success value.retryconstRetries typed failures from an effect according to a retry policy.retryOrElseconstRetries a failing effect and runs a fallback effect if retries are exhausted.sandboxconstExposes an effect's full failure cause in the error channel as Cause<E>.TagsWithReasontypeType helper that keeps only error tags whose tagged error contains a tagged reason field.unwrapReasonconstPromotes nested reason errors into the Effect error channel, replacing the parent error.withErrorReportingconstRuns an effect and reports any errors to the configured ErrorReporters.Fallback
firstSuccessOfconstRuns a sequence of effects and returns the result of the first successful one.orElseSucceedconstRecovers from a typed failure by producing a fallback success value.withExecutionPlanconstApplies an ExecutionPlan to an effect, retrying with step-provided resources until it succeeds or the plan is exhausted.Functions
Interruption
abortSignalconstCreates an AbortSignal that is managed by the provided scope.interruptconstReturns an effect that is immediately interrupted.interruptibleconstReturns a new effect that allows the effect to be interruptible.interruptibleMaskconstRuns an effect in an interruptible region while providing restore for locally restoring the previous interruptibility.onInterruptconstRuns the specified finalizer effect if this effect is interrupted.uninterruptibleconstReturns a new effect that disables interruption for the given effect.uninterruptibleMaskconstDisables interruption and provides a restore function to restore the interruptible state within the effect.Outcome Encapsulation
Pattern Matching
matchconstHandles both success and failure cases of an effect without performing side effects.matchCauseconstHandles failures by matching the cause of failure.matchCauseEagerconstHandles failures by matching the cause of failure with eager evaluation.matchCauseEffectconstHandles failures with access to the cause and allows performing side effects.matchCauseEffectEagerconstHandles success or failure eagerly with effectful handlers when the effect is already resolved.matchEagerconstHandles both success and failure cases of an effect without performing side effects, with eager evaluation for resolved effects.matchEffectconstHandles both success and failure by running effectful handlers.Racing
raceconstRaces two effects and returns the first successful result.raceAllconstRuns multiple effects concurrently and returns the first successful result.raceAllFirstconstRuns multiple effects concurrently and completes with the first effect to finish, whether it succeeds or fails.raceFirstconstRaces two effects and returns the result of the first one to complete, whether it succeeds or fails.References
Repetition
eventuallyconstRetries an effect until it succeeds, discarding failures.foreverconstRepeats this effect forever (until the first error).repeatconstRepeats an effect based on a specified schedule or until the first failure.repeatOrElseconstRepeats an effect according to a schedule and runs a fallback effect if repetition fails before the schedule completes.scheduleconstRuns an effect repeatedly according to a schedule and returns the schedule's final output.scheduleFromconstRuns an effect repeatedly according to a schedule that is initialized with a specific schedule input.Requests & Batching
Resource Management
acquireDisposableconstAcquires a scoped resource that implements JavaScript disposal protocols.acquireReleaseconstConstructs a scoped resource from an acquisition effect and a release finalizer.acquireUseReleaseconstRuns resource acquisition, usage, and release as one bracketed effect.addFinalizerconstAdds a finalizer to the current scope.ensuringconstReturns an effect that, if this effect _starts_ execution, then the specified finalizer is guaranteed to be executed, whether this effect succeeds, fails, or is interrupted.onErrorconstRuns the specified effect if this effect fails, providing the error to the effect if it exists.onErrorFilterconstRuns the finalizer only when this effect fails and the cause matches the provided Filter.onErrorIfconstRuns the finalizer only when this effect fails and the Cause matches the provided predicate.onExitconstEnsures that a cleanup function runs whether this effect succeeds, fails, or is interrupted.onExitFilterconstRuns the cleanup effect only when the Exit matches the provided Filter.onExitIfconstRuns the cleanup effect only when the Exit satisfies the provided predicate.onExitPrimitiveconstRuns an optional finalizer with the effect's Exit value when the effect completes.scopeconstReturns the current scope for resource management.scopedconstRuns an effect with a scope that closes when the effect completes.scopedWithconstCreates a scoped effect by providing access to the scope.Running
runCallbackconstRuns an effect asynchronously, registering onExit as a fiber observer and returning an interruptor.runCallbackWithconstForks an effect with the provided services, registers onExit as a fiber observer, and returns an interruptor.runForkconstRuns an effect in the background, returning a fiber that can be observed or interrupted.runForkWithconstRuns an effect in the background with the provided services.RunOptionsinterfaceConfiguration options for running Effect programs, providing control over interruption and scheduling behavior.runPromiseconstExecutes an effect and returns the result as a Promise.runPromiseExitconstRuns an effect and returns a Promise that resolves to an Exit, which represents the outcome (success or failure) of the effect.runPromiseExitWithconstRuns an effect and returns a Promise of Exit with provided services.runPromiseWithconstExecutes an effect as a Promise with the provided services.runSyncconstExecutes an effect synchronously and returns its success value.runSyncExitconstRuns an effect synchronously and captures the outcome safely as an Exit type, which represents the outcome (success or failure) of the effect.runSyncExitWithconstRuns an effect synchronously with provided services, returning an Exit result safely.runSyncWithconstExecutes an effect synchronously with provided services.Supervision & Fibers
awaitAllChildrenconstWaits for all child fibers forked by this effect to complete before this effect completes.fiberconstAccesses the fiber currently executing the effect.fiberIdconstAccesses the current fiber id executing the effect.forkChildconstReturns an effect that forks this effect into its own separate fiber, returning the fiber immediately, without waiting for it to begin executing the effect.forkDetachconstForks the effect into a new fiber attached to the global scope.forkInconstForks the effect in the specified scope.forkScopedconstForks the fiber in a Scope, interrupting it when the scope is closed.Tracing
annotateCurrentSpanconstAdds an annotation to the current span if available.annotateSpansconstAdds an annotation to each span in this effect.currentParentSpanconstReturns the current parent span from the effect context.currentSpanconstReturns the currently active local tracing span.linkSpansconstAdds a link with the provided span to all spans in this effect.makeSpanconstCreates a new tracing span and returns it without managing its lifetime.makeSpanScopedconstCreate a new span for tracing, and automatically close it when the Scope finalizes.spanAnnotationsconstReturns the tracing span annotations currently carried in the effect context.spanLinksconstReturns the tracing span links currently carried in the effect context.tracerconstReturns the current tracer from the context.useSpanconstCreate a new span for tracing, and automatically close it when the effect completes.withParentSpanconstAdds the provided span to the current span stack.withSpanconstWraps the effect with a child span for tracing.withSpanScopedconstWraps the effect with a scoped child span for tracing.withTracerconstProvides a tracer to an effect.withTracerEnabledconstEnables or disables tracing for spans created by the given effect.withTracerTimingconstEnables or disables tracer timing for the given Effect.Tracking
trackconstUpdates the Metric every time the Effect is executed.trackDefectsconstUpdates the provided Metric every time the wrapped Effect fails with an unexpected error (i.e.trackDurationconstUpdates the provided Metric with the Duration of time (in nanoseconds) that the wrapped Effect took to complete.trackErrorsconstUpdates the provided Metric every time the wrapped Effect fails with an expected error.trackSuccessesconstUpdates the provided Metric every time the wrapped Effect succeeds with a value.Transactions
Type Lambdas
Utility Types
Zipping
Namespaces
AllnamespaceNamespace containing type utilities for the Effect.all function, which handles collecting multiple effects into various output structures.EffectifynamespaceType helpers for converting callback-based functions into Effect functions.RepeatnamespaceType helpers for repeating effects.RetrynamespaceType helpers for retrying effects.