effect 4.0.0-beta.3 → 4.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Array.d.ts +126 -299
- package/dist/Array.d.ts.map +1 -1
- package/dist/Array.js +102 -62
- package/dist/Array.js.map +1 -1
- package/dist/Brand.d.ts +1 -1
- package/dist/Brand.d.ts.map +1 -1
- package/dist/Brand.js +1 -1
- package/dist/Brand.js.map +1 -1
- package/dist/Cache.d.ts +2 -2
- package/dist/Cache.d.ts.map +1 -1
- package/dist/Cache.js +6 -5
- package/dist/Cache.js.map +1 -1
- package/dist/Cause.d.ts +2 -2
- package/dist/Cause.d.ts.map +1 -1
- package/dist/Channel.d.ts +116 -30
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +82 -37
- package/dist/Channel.js.map +1 -1
- package/dist/Chunk.d.ts +54 -247
- package/dist/Chunk.d.ts.map +1 -1
- package/dist/Chunk.js +36 -67
- package/dist/Chunk.js.map +1 -1
- package/dist/Combiner.d.ts +280 -13
- package/dist/Combiner.d.ts.map +1 -1
- package/dist/Combiner.js +198 -7
- package/dist/Combiner.js.map +1 -1
- package/dist/Config.d.ts +165 -9
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +65 -10
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +1 -1
- package/dist/Cron.d.ts +1 -1
- package/dist/Data.d.ts +535 -366
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js +132 -79
- package/dist/Data.js.map +1 -1
- package/dist/DateTime.d.ts +23 -161
- package/dist/DateTime.d.ts.map +1 -1
- package/dist/DateTime.js +6 -51
- package/dist/DateTime.js.map +1 -1
- package/dist/Duration.d.ts +11 -11
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +11 -11
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +1206 -924
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +390 -329
- package/dist/Effect.js.map +1 -1
- package/dist/Encoding.d.ts +194 -0
- package/dist/Encoding.d.ts.map +1 -0
- package/dist/Encoding.js +352 -0
- package/dist/Encoding.js.map +1 -0
- package/dist/Equal.d.ts +276 -109
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +124 -48
- package/dist/Equal.js.map +1 -1
- package/dist/ErrorReporter.d.ts +374 -0
- package/dist/ErrorReporter.d.ts.map +1 -0
- package/dist/ErrorReporter.js +244 -0
- package/dist/ErrorReporter.js.map +1 -0
- package/dist/Exit.d.ts +24 -12
- package/dist/Exit.d.ts.map +1 -1
- package/dist/Exit.js +8 -4
- package/dist/Exit.js.map +1 -1
- package/dist/Fiber.d.ts +3 -2
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/FileSystem.d.ts +1 -1
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +5 -5
- package/dist/FileSystem.js.map +1 -1
- package/dist/Filter.d.ts +34 -38
- package/dist/Filter.d.ts.map +1 -1
- package/dist/Filter.js +15 -13
- package/dist/Filter.js.map +1 -1
- package/dist/Formatter.d.ts +131 -47
- package/dist/Formatter.d.ts.map +1 -1
- package/dist/Formatter.js +229 -51
- package/dist/Formatter.js.map +1 -1
- package/dist/Function.d.ts +1 -9
- package/dist/Function.d.ts.map +1 -1
- package/dist/Function.js +2 -10
- package/dist/Function.js.map +1 -1
- package/dist/Graph.d.ts +1 -1
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +5 -8
- package/dist/Graph.js.map +1 -1
- package/dist/HashMap.d.ts +15 -14
- package/dist/HashMap.d.ts.map +1 -1
- package/dist/HashMap.js +4 -4
- package/dist/HashMap.js.map +1 -1
- package/dist/Iterable.d.ts +39 -39
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +94 -22
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonSchema.d.ts +299 -10
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +323 -4
- package/dist/JsonSchema.js.map +1 -1
- package/dist/Latch.d.ts +109 -0
- package/dist/Latch.d.ts.map +1 -0
- package/dist/Latch.js +72 -0
- package/dist/Latch.js.map +1 -0
- package/dist/Layer.d.ts +121 -126
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +43 -44
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +8 -8
- package/dist/LayerMap.d.ts.map +1 -1
- package/dist/LayerMap.js +3 -3
- package/dist/LogLevel.d.ts +32 -0
- package/dist/LogLevel.d.ts.map +1 -1
- package/dist/LogLevel.js +28 -100
- package/dist/LogLevel.js.map +1 -1
- package/dist/Logger.d.ts +29 -95
- package/dist/Logger.d.ts.map +1 -1
- package/dist/Logger.js +2 -3
- package/dist/Logger.js.map +1 -1
- package/dist/ManagedRuntime.d.ts +2 -2
- package/dist/ManagedRuntime.js +2 -2
- package/dist/Metric.d.ts +4 -6
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +3 -5
- package/dist/Metric.js.map +1 -1
- package/dist/Newtype.d.ts +291 -0
- package/dist/Newtype.d.ts.map +1 -0
- package/dist/Newtype.js +161 -0
- package/dist/Newtype.js.map +1 -0
- package/dist/Optic.d.ts +947 -18
- package/dist/Optic.d.ts.map +1 -1
- package/dist/Optic.js +454 -5
- package/dist/Optic.js.map +1 -1
- package/dist/Option.d.ts +23 -16
- package/dist/Option.d.ts.map +1 -1
- package/dist/Option.js +15 -9
- package/dist/Option.js.map +1 -1
- package/dist/Pipeable.d.ts +17 -0
- package/dist/Pipeable.d.ts.map +1 -1
- package/dist/Pipeable.js +19 -1
- package/dist/Pipeable.js.map +1 -1
- package/dist/PlatformError.d.ts +10 -9
- package/dist/PlatformError.d.ts.map +1 -1
- package/dist/PlatformError.js +2 -2
- package/dist/PlatformError.js.map +1 -1
- package/dist/Pool.d.ts +6 -4
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +7 -5
- package/dist/Pool.js.map +1 -1
- package/dist/PubSub.d.ts +3 -2
- package/dist/PubSub.d.ts.map +1 -1
- package/dist/PubSub.js +3 -2
- package/dist/PubSub.js.map +1 -1
- package/dist/Pull.d.ts.map +1 -1
- package/dist/Pull.js +1 -1
- package/dist/Pull.js.map +1 -1
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +0 -1
- package/dist/Queue.js.map +1 -1
- package/dist/Random.d.ts +35 -1
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +46 -12
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts +2 -2
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +1 -1
- package/dist/RcMap.js.map +1 -1
- package/dist/RcRef.d.ts +1 -1
- package/dist/RcRef.d.ts.map +1 -1
- package/dist/Record.d.ts +23 -120
- package/dist/Record.d.ts.map +1 -1
- package/dist/Record.js +21 -41
- package/dist/Record.js.map +1 -1
- package/dist/Reducer.d.ts +166 -7
- package/dist/Reducer.d.ts.map +1 -1
- package/dist/Reducer.js +135 -1
- package/dist/Reducer.js.map +1 -1
- package/dist/References.d.ts +9 -4
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +6 -1
- package/dist/References.js.map +1 -1
- package/dist/Request.d.ts +1 -1
- package/dist/Request.d.ts.map +1 -1
- package/dist/Request.js +2 -1
- package/dist/Request.js.map +1 -1
- package/dist/RequestResolver.d.ts +25 -45
- package/dist/RequestResolver.d.ts.map +1 -1
- package/dist/RequestResolver.js +10 -30
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Result.d.ts +1 -1
- package/dist/Result.d.ts.map +1 -1
- package/dist/Result.js +1 -2
- package/dist/Result.js.map +1 -1
- package/dist/Runtime.d.ts +66 -0
- package/dist/Runtime.d.ts.map +1 -1
- package/dist/Runtime.js +79 -6
- package/dist/Runtime.js.map +1 -1
- package/dist/Schedule.d.ts +191 -102
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +152 -66
- package/dist/Schedule.js.map +1 -1
- package/dist/Scheduler.d.ts +9 -0
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +11 -0
- package/dist/Scheduler.js.map +1 -1
- package/dist/Schema.d.ts +309 -88
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +499 -109
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +129 -23
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +5 -5
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +12 -14
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaParser.d.ts +5 -0
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +10 -0
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +44 -43
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +49 -24
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +107 -3
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +159 -4
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.d.ts +2 -2
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +1 -1
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts +211 -0
- package/dist/Semaphore.d.ts.map +1 -0
- package/dist/{PartitionedSemaphore.js → Semaphore.js} +97 -13
- package/dist/Semaphore.js.map +1 -0
- package/dist/ServiceMap.d.ts +41 -31
- package/dist/ServiceMap.d.ts.map +1 -1
- package/dist/ServiceMap.js +3 -3
- package/dist/ServiceMap.js.map +1 -1
- package/dist/Sink.d.ts +13 -13
- package/dist/Sink.d.ts.map +1 -1
- package/dist/Sink.js +53 -6
- package/dist/Sink.js.map +1 -1
- package/dist/Stdio.d.ts +16 -4
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +18 -0
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +250 -428
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +137 -82
- package/dist/Stream.js.map +1 -1
- package/dist/Struct.d.ts +16 -0
- package/dist/Struct.d.ts.map +1 -1
- package/dist/Struct.js +22 -0
- package/dist/Struct.js.map +1 -1
- package/dist/SubscriptionRef.d.ts +2 -1
- package/dist/SubscriptionRef.d.ts.map +1 -1
- package/dist/SubscriptionRef.js +2 -1
- package/dist/SubscriptionRef.js.map +1 -1
- package/dist/SynchronizedRef.d.ts +2 -1
- package/dist/SynchronizedRef.d.ts.map +1 -1
- package/dist/SynchronizedRef.js +2 -1
- package/dist/SynchronizedRef.js.map +1 -1
- package/dist/Trie.d.ts +18 -17
- package/dist/Trie.d.ts.map +1 -1
- package/dist/Trie.js +5 -5
- package/dist/Trie.js.map +1 -1
- package/dist/TxChunk.d.ts +37 -37
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +3 -3
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +328 -0
- package/dist/TxDeferred.d.ts.map +1 -0
- package/dist/TxDeferred.js +196 -0
- package/dist/TxDeferred.js.map +1 -0
- package/dist/TxHashMap.d.ts +84 -83
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +24 -24
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +35 -35
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +14 -14
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +609 -0
- package/dist/TxPriorityQueue.d.ts.map +1 -0
- package/dist/TxPriorityQueue.js +415 -0
- package/dist/TxPriorityQueue.js.map +1 -0
- package/dist/TxPubSub.d.ts +585 -0
- package/dist/TxPubSub.d.ts.map +1 -0
- package/dist/TxPubSub.js +521 -0
- package/dist/TxPubSub.js.map +1 -0
- package/dist/TxQueue.d.ts +32 -32
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +26 -26
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +523 -0
- package/dist/TxReentrantLock.d.ts.map +1 -0
- package/dist/TxReentrantLock.js +504 -0
- package/dist/TxReentrantLock.js.map +1 -0
- package/dist/TxRef.d.ts +34 -34
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +21 -14
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +8 -8
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +7 -7
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +508 -0
- package/dist/TxSubscriptionRef.d.ts.map +1 -0
- package/dist/TxSubscriptionRef.js +293 -0
- package/dist/TxSubscriptionRef.js.map +1 -0
- package/dist/Types.d.ts +80 -23
- package/dist/Types.d.ts.map +1 -1
- package/dist/Utils.d.ts +137 -65
- package/dist/Utils.d.ts.map +1 -1
- package/dist/Utils.js +38 -66
- package/dist/Utils.js.map +1 -1
- package/dist/index.d.ts +718 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +718 -23
- package/dist/index.js.map +1 -1
- package/dist/internal/core.js +11 -3
- package/dist/internal/core.js.map +1 -1
- package/dist/internal/dateTime.js +3 -11
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +264 -126
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/hashMap.js +5 -4
- package/dist/internal/hashMap.js.map +1 -1
- package/dist/internal/random.d.ts +2 -0
- package/dist/internal/random.d.ts.map +1 -0
- package/dist/internal/random.js +13 -0
- package/dist/internal/random.js.map +1 -0
- package/dist/internal/rcRef.js +3 -2
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/request.js +2 -2
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schema/annotations.js +2 -0
- package/dist/internal/schema/annotations.js.map +1 -1
- package/dist/internal/schema/representation.js +47 -106
- package/dist/internal/schema/representation.js.map +1 -1
- package/dist/internal/schema/schema.js +1 -0
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/internal/schema/to-codec.js +7 -10
- package/dist/internal/schema/to-codec.js.map +1 -1
- package/dist/internal/trie.js +5 -4
- package/dist/internal/trie.js.map +1 -1
- package/dist/testing/TestClock.d.ts +8 -7
- package/dist/testing/TestClock.d.ts.map +1 -1
- package/dist/testing/TestClock.js +6 -4
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +266 -32
- package/dist/testing/TestSchema.d.ts.map +1 -1
- package/dist/testing/TestSchema.js +296 -23
- package/dist/testing/TestSchema.js.map +1 -1
- package/dist/testing/index.d.ts +64 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +64 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/unstable/ai/AiError.d.ts +134 -51
- package/dist/unstable/ai/AiError.d.ts.map +1 -1
- package/dist/unstable/ai/AiError.js +19 -16
- package/dist/unstable/ai/AiError.js.map +1 -1
- package/dist/unstable/ai/Chat.d.ts +5 -5
- package/dist/unstable/ai/Chat.d.ts.map +1 -1
- package/dist/unstable/ai/Chat.js +38 -44
- package/dist/unstable/ai/Chat.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +16 -30
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +97 -37
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +183 -88
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +57 -12
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +66 -13
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +193 -51
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Model.d.ts +25 -7
- package/dist/unstable/ai/Model.d.ts.map +1 -1
- package/dist/unstable/ai/Model.js +22 -6
- package/dist/unstable/ai/Model.js.map +1 -1
- package/dist/unstable/ai/Prompt.d.ts +20 -20
- package/dist/unstable/ai/Prompt.d.ts.map +1 -1
- package/dist/unstable/ai/Response.d.ts +26 -26
- package/dist/unstable/ai/Response.d.ts.map +1 -1
- package/dist/unstable/ai/Response.js +1 -1
- package/dist/unstable/ai/Response.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +20 -4
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +14 -9
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/ai/Toolkit.d.ts +1 -1
- package/dist/unstable/ai/Toolkit.d.ts.map +1 -1
- package/dist/unstable/ai/Toolkit.js +4 -11
- package/dist/unstable/ai/Toolkit.js.map +1 -1
- package/dist/unstable/ai/index.d.ts +1 -1
- package/dist/unstable/ai/index.js +1 -1
- package/dist/unstable/ai/internal/codec-transformer.js +0 -5
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/cli/CliError.d.ts +27 -60
- package/dist/unstable/cli/CliError.d.ts.map +1 -1
- package/dist/unstable/cli/CliError.js +25 -57
- package/dist/unstable/cli/CliError.js.map +1 -1
- package/dist/unstable/cli/CliOutput.js +59 -6
- package/dist/unstable/cli/CliOutput.js.map +1 -1
- package/dist/unstable/cli/Command.d.ts +368 -56
- package/dist/unstable/cli/Command.d.ts.map +1 -1
- package/dist/unstable/cli/Command.js +325 -64
- package/dist/unstable/cli/Command.js.map +1 -1
- package/dist/unstable/cli/GlobalFlag.d.ts +125 -0
- package/dist/unstable/cli/GlobalFlag.d.ts.map +1 -0
- package/dist/unstable/cli/GlobalFlag.js +118 -0
- package/dist/unstable/cli/GlobalFlag.js.map +1 -0
- package/dist/unstable/cli/HelpDoc.d.ts +70 -2
- package/dist/unstable/cli/HelpDoc.d.ts.map +1 -1
- package/dist/unstable/cli/Primitive.d.ts +1 -1
- package/dist/unstable/cli/Primitive.js +1 -1
- package/dist/unstable/cli/Prompt.js +35 -8
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cli/index.d.ts +4 -0
- package/dist/unstable/cli/index.d.ts.map +1 -1
- package/dist/unstable/cli/index.js +4 -0
- package/dist/unstable/cli/index.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts +40 -14
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +72 -46
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js +7 -2
- package/dist/unstable/cli/internal/completions/CommandDescriptor.js.map +1 -1
- package/dist/unstable/cli/internal/config.js +42 -0
- package/dist/unstable/cli/internal/config.js.map +1 -1
- package/dist/unstable/cli/internal/help.d.ts +33 -0
- package/dist/unstable/cli/internal/help.d.ts.map +1 -0
- package/dist/unstable/cli/internal/help.js +125 -0
- package/dist/unstable/cli/internal/help.js.map +1 -0
- package/dist/unstable/cli/internal/parser.js +55 -42
- package/dist/unstable/cli/internal/parser.js.map +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts +1 -1
- package/dist/unstable/cluster/ClusterCron.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterCron.js +1 -1
- package/dist/unstable/cluster/ClusterCron.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +4 -3
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/cluster/Entity.d.ts +7 -6
- package/dist/unstable/cluster/Entity.d.ts.map +1 -1
- package/dist/unstable/cluster/Entity.js.map +1 -1
- package/dist/unstable/cluster/EntityResource.d.ts +2 -2
- package/dist/unstable/cluster/EntityResource.d.ts.map +1 -1
- package/dist/unstable/cluster/Envelope.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
- package/dist/unstable/cluster/K8sHttpClient.js +4 -4
- package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +10 -10
- package/dist/unstable/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/MessageStorage.js +2 -1
- package/dist/unstable/cluster/MessageStorage.js.map +1 -1
- package/dist/unstable/cluster/Reply.d.ts +6 -6
- package/dist/unstable/cluster/Runner.d.ts +1 -1
- package/dist/unstable/cluster/Runners.d.ts.map +1 -1
- package/dist/unstable/cluster/Runners.js +4 -3
- package/dist/unstable/cluster/Runners.js.map +1 -1
- package/dist/unstable/cluster/Sharding.d.ts +2 -2
- package/dist/unstable/cluster/Sharding.d.ts.map +1 -1
- package/dist/unstable/cluster/Sharding.js +9 -7
- package/dist/unstable/cluster/Sharding.js.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.d.ts +21 -21
- package/dist/unstable/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/unstable/cluster/ShardingConfig.js +20 -20
- package/dist/unstable/cluster/ShardingConfig.js.map +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js +1 -1
- package/dist/unstable/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/unstable/cluster/internal/entityManager.js +5 -4
- package/dist/unstable/cluster/internal/entityManager.js.map +1 -1
- package/dist/unstable/cluster/internal/entityReaper.js +2 -1
- package/dist/unstable/cluster/internal/entityReaper.js.map +1 -1
- package/dist/unstable/cluster/internal/resourceRef.js +2 -1
- package/dist/unstable/cluster/internal/resourceRef.js.map +1 -1
- package/dist/unstable/devtools/DevToolsSchema.d.ts +36 -36
- package/dist/unstable/encoding/Msgpack.d.ts +1 -1
- package/dist/unstable/encoding/Ndjson.d.ts +1 -1
- package/dist/unstable/encoding/Sse.d.ts +4 -4
- package/dist/unstable/encoding/Sse.d.ts.map +1 -1
- package/dist/unstable/encoding/Sse.js +1 -1
- package/dist/unstable/encoding/Sse.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +2 -2
- package/dist/unstable/eventlog/EventLog.d.ts.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +2 -1
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +6 -6
- package/dist/unstable/http/Cookies.d.ts +47 -3
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +24 -2
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/Headers.d.ts +16 -0
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +38 -10
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +3 -3
- package/dist/unstable/http/HttpBody.d.ts.map +1 -1
- package/dist/unstable/http/HttpBody.js +6 -6
- package/dist/unstable/http/HttpBody.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +117 -15
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +189 -12
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpClientError.d.ts +7 -7
- package/dist/unstable/http/HttpClientRequest.d.ts +16 -11
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +31 -20
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpClientResponse.d.ts +2 -1
- package/dist/unstable/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientResponse.js +4 -0
- package/dist/unstable/http/HttpClientResponse.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +7 -5
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +46 -54
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpMethod.d.ts +4 -4
- package/dist/unstable/http/HttpMethod.d.ts.map +1 -1
- package/dist/unstable/http/HttpMethod.js +3 -3
- package/dist/unstable/http/HttpMethod.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts +1 -6
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +8 -17
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +20 -33
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +37 -44
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/HttpServerRequest.d.ts +12 -1
- package/dist/unstable/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRequest.js +291 -1
- package/dist/unstable/http/HttpServerRequest.js.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.d.ts +2 -2
- package/dist/unstable/http/HttpServerRespondable.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerRespondable.js +5 -5
- package/dist/unstable/http/HttpServerRespondable.js.map +1 -1
- package/dist/unstable/http/HttpServerResponse.d.ts +50 -3
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +234 -1
- package/dist/unstable/http/HttpServerResponse.js.map +1 -1
- package/dist/unstable/http/HttpStaticServer.d.ts +69 -0
- package/dist/unstable/http/HttpStaticServer.d.ts.map +1 -0
- package/dist/unstable/http/HttpStaticServer.js +353 -0
- package/dist/unstable/http/HttpStaticServer.js.map +1 -0
- package/dist/unstable/http/Multipart.d.ts +3 -3
- package/dist/unstable/http/UrlParams.d.ts +14 -6
- package/dist/unstable/http/UrlParams.d.ts.map +1 -1
- package/dist/unstable/http/UrlParams.js +1 -1
- package/dist/unstable/http/UrlParams.js.map +1 -1
- package/dist/unstable/http/index.d.ts +4 -0
- package/dist/unstable/http/index.d.ts.map +1 -1
- package/dist/unstable/http/index.js +4 -0
- package/dist/unstable/http/index.js.map +1 -1
- package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
- package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js +10 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
- package/dist/unstable/httpapi/HttpApi.d.ts +4 -4
- package/dist/unstable/httpapi/HttpApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApi.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +11 -5
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +28 -18
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +66 -6
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +40 -3
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +41 -54
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +17 -26
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.d.ts +16 -14
- package/dist/unstable/httpapi/HttpApiError.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiError.js +44 -29
- package/dist/unstable/httpapi/HttpApiError.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.d.ts +4 -3
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts +4 -4
- package/dist/unstable/httpapi/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiMiddleware.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +6 -0
- package/dist/unstable/httpapi/HttpApiScalar.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts +2 -2
- package/dist/unstable/httpapi/HttpApiSecurity.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSecurity.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +32 -21
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/observability/Otlp.d.ts +12 -12
- package/dist/unstable/observability/Otlp.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.d.ts +2 -2
- package/dist/unstable/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpExporter.js +1 -1
- package/dist/unstable/observability/OtlpExporter.js.map +1 -1
- package/dist/unstable/observability/OtlpLogger.d.ts +4 -4
- package/dist/unstable/observability/OtlpLogger.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpLogger.js +7 -4
- package/dist/unstable/observability/OtlpLogger.js.map +1 -1
- package/dist/unstable/observability/OtlpMetrics.d.ts +4 -4
- package/dist/unstable/observability/OtlpMetrics.d.ts.map +1 -1
- package/dist/unstable/observability/OtlpTracer.d.ts +4 -4
- package/dist/unstable/observability/OtlpTracer.d.ts.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +1 -1
- package/dist/unstable/persistence/KeyValueStore.js +6 -6
- package/dist/unstable/persistence/KeyValueStore.js.map +1 -1
- package/dist/unstable/persistence/Persistable.d.ts +2 -2
- package/dist/unstable/persistence/Persistable.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.d.ts +6 -5
- package/dist/unstable/persistence/PersistedCache.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedCache.js +2 -1
- package/dist/unstable/persistence/PersistedCache.js.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.d.ts +12 -12
- package/dist/unstable/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/unstable/persistence/PersistedQueue.js +12 -11
- package/dist/unstable/persistence/PersistedQueue.js.map +1 -1
- package/dist/unstable/persistence/Persistence.d.ts +1 -1
- package/dist/unstable/persistence/Persistence.d.ts.map +1 -1
- package/dist/unstable/persistence/Persistence.js +2 -2
- package/dist/unstable/persistence/Persistence.js.map +1 -1
- package/dist/unstable/persistence/RateLimiter.d.ts +3 -3
- package/dist/unstable/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/unstable/persistence/RateLimiter.js +1 -1
- package/dist/unstable/persistence/RateLimiter.js.map +1 -1
- package/dist/unstable/process/ChildProcess.d.ts +5 -128
- package/dist/unstable/process/ChildProcess.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcess.js +1 -65
- package/dist/unstable/process/ChildProcess.js.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.d.ts +45 -7
- package/dist/unstable/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/unstable/process/ChildProcessSpawner.js +21 -1
- package/dist/unstable/process/ChildProcessSpawner.js.map +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +73 -12
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +107 -20
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +10 -12
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +42 -12
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.d.ts +6 -0
- package/dist/unstable/reactivity/AtomRegistry.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +50 -9
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +9 -9
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +47 -21
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/reactivity/Hydration.d.ts +39 -0
- package/dist/unstable/reactivity/Hydration.d.ts.map +1 -0
- package/dist/unstable/reactivity/Hydration.js +76 -0
- package/dist/unstable/reactivity/Hydration.js.map +1 -0
- package/dist/unstable/reactivity/index.d.ts +4 -0
- package/dist/unstable/reactivity/index.d.ts.map +1 -1
- package/dist/unstable/reactivity/index.js +4 -0
- package/dist/unstable/reactivity/index.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +5 -5
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcClient.d.ts +5 -26
- package/dist/unstable/rpc/RpcClient.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcClient.js +6 -13
- package/dist/unstable/rpc/RpcClient.js.map +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts +2 -2
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +8 -8
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +14 -0
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +34 -9
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +5 -9
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +17 -17
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/Utils.d.ts.map +1 -1
- package/dist/unstable/rpc/Utils.js +3 -2
- package/dist/unstable/rpc/Utils.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +22 -1
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +15 -0
- package/dist/unstable/schema/Model.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +5 -5
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/dist/unstable/schema/VariantSchema.js +6 -6
- package/dist/unstable/schema/VariantSchema.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +4 -4
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +6 -5
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/socket/SocketServer.d.ts +3 -3
- package/dist/unstable/sql/Migrator.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts +1 -1
- package/dist/unstable/sql/SqlClient.d.ts.map +1 -1
- package/dist/unstable/sql/SqlError.d.ts +14 -14
- package/dist/unstable/sql/SqlError.d.ts.map +1 -1
- package/dist/unstable/sql/SqlError.js +9 -3
- package/dist/unstable/sql/SqlError.js.map +1 -1
- package/dist/unstable/sql/SqlModel.d.ts +2 -2
- package/dist/unstable/sql/SqlModel.d.ts.map +1 -1
- package/dist/unstable/sql/SqlModel.js +3 -3
- package/dist/unstable/sql/SqlModel.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +17 -8
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/sql/SqlSchema.d.ts +17 -6
- package/dist/unstable/sql/SqlSchema.d.ts.map +1 -1
- package/dist/unstable/sql/SqlSchema.js +17 -7
- package/dist/unstable/sql/SqlSchema.js.map +1 -1
- package/dist/unstable/sql/Statement.js +0 -1
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workers/Worker.d.ts.map +1 -1
- package/dist/unstable/workers/Worker.js +2 -1
- package/dist/unstable/workers/Worker.js.map +1 -1
- package/dist/unstable/workflow/DurableClock.d.ts +3 -3
- package/dist/unstable/workflow/DurableClock.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableClock.js +3 -3
- package/dist/unstable/workflow/DurableClock.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +2 -2
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +3 -3
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +1 -1
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts +12 -1
- package/dist/unstable/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +137 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +2 -2
- package/src/Array.ts +192 -342
- package/src/Brand.ts +1 -1
- package/src/Cache.ts +9 -8
- package/src/Cause.ts +2 -2
- package/src/Channel.ts +554 -138
- package/src/Chunk.ts +81 -268
- package/src/Combiner.ts +280 -13
- package/src/Config.ts +186 -24
- package/src/Data.ts +539 -376
- package/src/DateTime.ts +24 -164
- package/src/Duration.ts +13 -13
- package/src/Effect.ts +1477 -1126
- package/src/Encoding.ts +879 -0
- package/src/Equal.ts +278 -111
- package/src/ErrorReporter.ts +457 -0
- package/src/Exit.ts +24 -12
- package/src/Fiber.ts +10 -2
- package/src/FileSystem.ts +7 -8
- package/src/Filter.ts +52 -63
- package/src/Formatter.ts +253 -51
- package/src/Function.ts +2 -10
- package/src/Graph.ts +24 -11
- package/src/HashMap.ts +15 -14
- package/src/Iterable.ts +104 -50
- package/src/JsonSchema.ts +383 -10
- package/src/Latch.ts +112 -0
- package/src/Layer.ts +123 -132
- package/src/LayerMap.ts +9 -9
- package/src/LogLevel.ts +37 -0
- package/src/Logger.ts +33 -100
- package/src/ManagedRuntime.ts +2 -2
- package/src/Metric.ts +6 -8
- package/src/Newtype.ts +308 -0
- package/src/Optic.ts +948 -19
- package/src/Option.ts +32 -24
- package/src/Pipeable.ts +32 -1
- package/src/PlatformError.ts +5 -5
- package/src/Pool.ts +13 -11
- package/src/PubSub.ts +10 -9
- package/src/Pull.ts +1 -1
- package/src/Queue.ts +0 -1
- package/src/Random.ts +51 -14
- package/src/RcMap.ts +5 -5
- package/src/RcRef.ts +1 -1
- package/src/Record.ts +42 -152
- package/src/Reducer.ts +166 -7
- package/src/References.ts +10 -5
- package/src/Request.ts +3 -2
- package/src/RequestResolver.ts +29 -49
- package/src/Result.ts +2 -4
- package/src/Runtime.ts +102 -6
- package/src/Schedule.ts +462 -242
- package/src/Scheduler.ts +12 -0
- package/src/Schema.ts +796 -194
- package/src/SchemaAST.ts +164 -31
- package/src/SchemaGetter.ts +15 -17
- package/src/SchemaParser.ts +11 -0
- package/src/SchemaRepresentation.ts +49 -24
- package/src/SchemaTransformation.ts +189 -4
- package/src/ScopedCache.ts +3 -3
- package/src/Semaphore.ts +356 -0
- package/src/ServiceMap.ts +50 -40
- package/src/Sink.ts +78 -26
- package/src/Stdio.ts +27 -4
- package/src/Stream.ts +586 -608
- package/src/Struct.ts +26 -0
- package/src/SubscriptionRef.ts +3 -2
- package/src/SynchronizedRef.ts +3 -2
- package/src/Trie.ts +18 -17
- package/src/TxChunk.ts +72 -53
- package/src/TxDeferred.ts +394 -0
- package/src/TxHashMap.ts +332 -285
- package/src/TxHashSet.ts +111 -116
- package/src/TxPriorityQueue.ts +767 -0
- package/src/TxPubSub.ts +789 -0
- package/src/TxQueue.ts +241 -251
- package/src/TxReentrantLock.ts +753 -0
- package/src/TxRef.ts +50 -38
- package/src/TxSemaphore.ts +29 -32
- package/src/TxSubscriptionRef.ts +639 -0
- package/src/Types.ts +73 -19
- package/src/Utils.ts +137 -111
- package/src/index.ts +728 -24
- package/src/internal/core.ts +12 -5
- package/src/internal/dateTime.ts +9 -30
- package/src/internal/effect.ts +774 -301
- package/src/internal/hashMap.ts +8 -7
- package/src/internal/random.ts +20 -0
- package/src/internal/rcRef.ts +4 -3
- package/src/internal/request.ts +2 -2
- package/src/internal/schema/annotations.ts +2 -0
- package/src/internal/schema/representation.ts +45 -94
- package/src/internal/schema/schema.ts +1 -0
- package/src/internal/schema/to-codec.ts +7 -17
- package/src/internal/trie.ts +15 -9
- package/src/testing/TestClock.ts +13 -11
- package/src/testing/TestSchema.ts +332 -35
- package/src/testing/index.ts +64 -1
- package/src/unstable/ai/AiError.ts +105 -48
- package/src/unstable/ai/Chat.ts +47 -61
- package/src/unstable/ai/LanguageModel.ts +153 -68
- package/src/unstable/ai/McpSchema.ts +73 -13
- package/src/unstable/ai/McpServer.ts +271 -61
- package/src/unstable/ai/Model.ts +40 -9
- package/src/unstable/ai/Prompt.ts +37 -37
- package/src/unstable/ai/Response.ts +25 -25
- package/src/unstable/ai/Tool.ts +20 -14
- package/src/unstable/ai/Toolkit.ts +5 -14
- package/src/unstable/ai/index.ts +1 -1
- package/src/unstable/ai/internal/codec-transformer.ts +0 -7
- package/src/unstable/cli/CliError.ts +47 -59
- package/src/unstable/cli/CliOutput.ts +75 -6
- package/src/unstable/cli/Command.ts +796 -187
- package/src/unstable/cli/GlobalFlag.ts +243 -0
- package/src/unstable/cli/HelpDoc.ts +80 -2
- package/src/unstable/cli/Primitive.ts +1 -1
- package/src/unstable/cli/Prompt.ts +31 -9
- package/src/unstable/cli/index.ts +5 -0
- package/src/unstable/cli/internal/command.ts +109 -63
- package/src/unstable/cli/internal/completions/CommandDescriptor.ts +7 -2
- package/src/unstable/cli/internal/config.ts +49 -0
- package/src/unstable/cli/internal/help.ts +171 -0
- package/src/unstable/cli/internal/parser.ts +66 -61
- package/src/unstable/cluster/ClusterCron.ts +2 -2
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +5 -4
- package/src/unstable/cluster/Entity.ts +11 -10
- package/src/unstable/cluster/EntityResource.ts +4 -4
- package/src/unstable/cluster/Envelope.ts +1 -1
- package/src/unstable/cluster/K8sHttpClient.ts +5 -5
- package/src/unstable/cluster/MessageStorage.ts +3 -5
- package/src/unstable/cluster/Runners.ts +6 -5
- package/src/unstable/cluster/Sharding.ts +12 -10
- package/src/unstable/cluster/ShardingConfig.ts +30 -31
- package/src/unstable/cluster/SqlRunnerStorage.ts +1 -1
- package/src/unstable/cluster/internal/entityManager.ts +9 -8
- package/src/unstable/cluster/internal/entityReaper.ts +2 -1
- package/src/unstable/cluster/internal/resourceRef.ts +2 -1
- package/src/unstable/encoding/Sse.ts +3 -5
- package/src/unstable/eventlog/EventLog.ts +2 -1
- package/src/unstable/http/Cookies.ts +87 -3
- package/src/unstable/http/Headers.ts +62 -13
- package/src/unstable/http/HttpBody.ts +6 -6
- package/src/unstable/http/HttpClient.ts +374 -33
- package/src/unstable/http/HttpClientRequest.ts +38 -30
- package/src/unstable/http/HttpClientResponse.ts +7 -2
- package/src/unstable/http/HttpEffect.ts +54 -68
- package/src/unstable/http/HttpMethod.ts +16 -4
- package/src/unstable/http/HttpMiddleware.ts +9 -24
- package/src/unstable/http/HttpServerError.ts +42 -45
- package/src/unstable/http/HttpServerRequest.ts +389 -2
- package/src/unstable/http/HttpServerRespondable.ts +6 -6
- package/src/unstable/http/HttpServerResponse.ts +337 -4
- package/src/unstable/http/HttpStaticServer.ts +456 -0
- package/src/unstable/http/Multipart.ts +2 -2
- package/src/unstable/http/UrlParams.ts +20 -5
- package/src/unstable/http/index.ts +5 -0
- package/src/unstable/http/internal/preResponseHandler.ts +15 -0
- package/src/unstable/httpapi/HttpApi.ts +6 -6
- package/src/unstable/httpapi/HttpApiBuilder.ts +81 -28
- package/src/unstable/httpapi/HttpApiClient.ts +100 -11
- package/src/unstable/httpapi/HttpApiEndpoint.ts +71 -87
- package/src/unstable/httpapi/HttpApiError.ts +51 -28
- package/src/unstable/httpapi/HttpApiGroup.ts +7 -6
- package/src/unstable/httpapi/HttpApiMiddleware.ts +4 -4
- package/src/unstable/httpapi/HttpApiScalar.ts +6 -0
- package/src/unstable/httpapi/HttpApiSecurity.ts +3 -3
- package/src/unstable/httpapi/OpenApi.ts +41 -23
- package/src/unstable/observability/Otlp.ts +12 -12
- package/src/unstable/observability/OtlpExporter.ts +3 -3
- package/src/unstable/observability/OtlpLogger.ts +13 -9
- package/src/unstable/observability/OtlpMetrics.ts +4 -4
- package/src/unstable/observability/OtlpTracer.ts +4 -4
- package/src/unstable/persistence/KeyValueStore.ts +6 -6
- package/src/unstable/persistence/Persistable.ts +2 -2
- package/src/unstable/persistence/PersistedCache.ts +20 -9
- package/src/unstable/persistence/PersistedQueue.ts +25 -24
- package/src/unstable/persistence/Persistence.ts +3 -3
- package/src/unstable/persistence/RateLimiter.ts +4 -4
- package/src/unstable/process/ChildProcess.ts +6 -208
- package/src/unstable/process/ChildProcessSpawner.ts +75 -14
- package/src/unstable/reactivity/Atom.ts +211 -50
- package/src/unstable/reactivity/AtomHttpApi.ts +66 -31
- package/src/unstable/reactivity/AtomRegistry.ts +61 -9
- package/src/unstable/reactivity/AtomRpc.ts +51 -20
- package/src/unstable/reactivity/Hydration.ts +112 -0
- package/src/unstable/reactivity/index.ts +5 -0
- package/src/unstable/rpc/Rpc.ts +7 -9
- package/src/unstable/rpc/RpcClient.ts +12 -54
- package/src/unstable/rpc/RpcGroup.ts +4 -4
- package/src/unstable/rpc/RpcMiddleware.ts +15 -9
- package/src/unstable/rpc/RpcSchema.ts +17 -0
- package/src/unstable/rpc/RpcSerialization.ts +44 -9
- package/src/unstable/rpc/RpcServer.ts +28 -32
- package/src/unstable/rpc/Utils.ts +3 -2
- package/src/unstable/schema/Model.ts +31 -0
- package/src/unstable/schema/VariantSchema.ts +9 -9
- package/src/unstable/socket/Socket.ts +16 -17
- package/src/unstable/sql/SqlClient.ts +1 -1
- package/src/unstable/sql/SqlError.ts +11 -9
- package/src/unstable/sql/SqlModel.ts +5 -5
- package/src/unstable/sql/SqlResolver.ts +17 -7
- package/src/unstable/sql/SqlSchema.ts +42 -26
- package/src/unstable/sql/Statement.ts +0 -1
- package/src/unstable/workers/Worker.ts +2 -1
- package/src/unstable/workflow/DurableClock.ts +8 -8
- package/src/unstable/workflow/DurableDeferred.ts +2 -2
- package/src/unstable/workflow/Workflow.ts +6 -2
- package/src/unstable/workflow/WorkflowEngine.ts +185 -2
- package/dist/PartitionedSemaphore.d.ts +0 -52
- package/dist/PartitionedSemaphore.d.ts.map +0 -1
- package/dist/PartitionedSemaphore.js.map +0 -1
- package/dist/encoding/Base64.d.ts +0 -67
- package/dist/encoding/Base64.d.ts.map +0 -1
- package/dist/encoding/Base64.js +0 -146
- package/dist/encoding/Base64.js.map +0 -1
- package/dist/encoding/Base64Url.d.ts +0 -60
- package/dist/encoding/Base64Url.d.ts.map +0 -1
- package/dist/encoding/Base64Url.js +0 -89
- package/dist/encoding/Base64Url.js.map +0 -1
- package/dist/encoding/EncodingError.d.ts +0 -31
- package/dist/encoding/EncodingError.d.ts.map +0 -1
- package/dist/encoding/EncodingError.js +0 -22
- package/dist/encoding/EncodingError.js.map +0 -1
- package/dist/encoding/Hex.d.ts +0 -61
- package/dist/encoding/Hex.d.ts.map +0 -1
- package/dist/encoding/Hex.js +0 -115
- package/dist/encoding/Hex.js.map +0 -1
- package/dist/encoding/index.d.ts +0 -26
- package/dist/encoding/index.d.ts.map +0 -1
- package/dist/encoding/index.js +0 -27
- package/dist/encoding/index.js.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.d.ts +0 -7
- package/dist/unstable/cli/internal/builtInFlags.d.ts.map +0 -1
- package/dist/unstable/cli/internal/builtInFlags.js +0 -44
- package/dist/unstable/cli/internal/builtInFlags.js.map +0 -1
- package/src/PartitionedSemaphore.ts +0 -182
- package/src/encoding/Base64.ts +0 -366
- package/src/encoding/Base64Url.ts +0 -104
- package/src/encoding/EncodingError.ts +0 -35
- package/src/encoding/Hex.ts +0 -390
- package/src/encoding/index.ts +0 -31
- package/src/unstable/cli/internal/builtInFlags.ts +0 -78
package/dist/Effect.d.ts
CHANGED
|
@@ -40,12 +40,14 @@
|
|
|
40
40
|
*
|
|
41
41
|
* @example
|
|
42
42
|
* ```ts
|
|
43
|
-
* import { Effect } from "effect"
|
|
43
|
+
* import { Data, Effect } from "effect"
|
|
44
|
+
*
|
|
45
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
44
46
|
*
|
|
45
47
|
* // Effect that may fail
|
|
46
48
|
* const divide = (a: number, b: number) =>
|
|
47
49
|
* b === 0
|
|
48
|
-
* ? Effect.fail(new
|
|
50
|
+
* ? Effect.fail(new DiscountRateError())
|
|
49
51
|
* : Effect.succeed(a / b)
|
|
50
52
|
*
|
|
51
53
|
* // Error handling
|
|
@@ -78,7 +80,7 @@ import { type LazyArg } from "./Function.ts";
|
|
|
78
80
|
import type { TypeLambda } from "./HKT.ts";
|
|
79
81
|
import type * as Layer from "./Layer.ts";
|
|
80
82
|
import type { Logger } from "./Logger.ts";
|
|
81
|
-
import type {
|
|
83
|
+
import type { Severity } from "./LogLevel.ts";
|
|
82
84
|
import * as Metric from "./Metric.ts";
|
|
83
85
|
import type { Option } from "./Option.ts";
|
|
84
86
|
import type { Pipeable } from "./Pipeable.ts";
|
|
@@ -92,7 +94,7 @@ import type { Scope } from "./Scope.ts";
|
|
|
92
94
|
import * as ServiceMap from "./ServiceMap.ts";
|
|
93
95
|
import type { AnySpan, ParentSpan, Span, SpanLink, SpanOptions, SpanOptionsNoTrace, TraceOptions, Tracer } from "./Tracer.ts";
|
|
94
96
|
import type { TxRef } from "./TxRef.ts";
|
|
95
|
-
import type { Concurrency, Covariant, EqualsWith, ExcludeReason, ExcludeTag, ExtractReason, ExtractTag, NoInfer, ReasonOf, ReasonTags, Tags, unassigned } from "./Types.ts";
|
|
97
|
+
import type { Concurrency, Covariant, EqualsWith, ExcludeReason, ExcludeTag, ExtractReason, ExtractTag, NarrowReason, NoInfer, OmitReason, ReasonOf, ReasonTags, Simplify, Tags, unassigned } from "./Types.ts";
|
|
96
98
|
import type * as Unify from "./Unify.ts";
|
|
97
99
|
declare const TypeId: "~effect/Effect";
|
|
98
100
|
/**
|
|
@@ -111,13 +113,15 @@ declare const TypeId: "~effect/Effect";
|
|
|
111
113
|
*
|
|
112
114
|
* @example
|
|
113
115
|
* ```ts
|
|
114
|
-
* import { Effect } from "effect"
|
|
116
|
+
* import { Data, Effect } from "effect"
|
|
117
|
+
*
|
|
118
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
115
119
|
*
|
|
116
120
|
* // A simple effect that succeeds with a value
|
|
117
121
|
* const success = Effect.succeed(42)
|
|
118
122
|
*
|
|
119
|
-
* // An effect that
|
|
120
|
-
* const risky = Effect.fail(new
|
|
123
|
+
* // An effect that will always fail
|
|
124
|
+
* const risky = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
121
125
|
*
|
|
122
126
|
* // Effects can be composed using generator functions
|
|
123
127
|
* const program = Effect.gen(function*() {
|
|
@@ -367,13 +371,15 @@ export declare namespace All {
|
|
|
367
371
|
* @category Models
|
|
368
372
|
* @example
|
|
369
373
|
* ```ts
|
|
370
|
-
* import { Effect } from "effect"
|
|
374
|
+
* import { Data, Effect } from "effect"
|
|
375
|
+
*
|
|
376
|
+
* class OopsError extends Data.TaggedError("OopsError")<{}> {}
|
|
371
377
|
*
|
|
372
378
|
* // EffectAny represents an Effect with any type parameters
|
|
373
379
|
* const effects: Array<Effect.All.EffectAny> = [
|
|
374
380
|
* Effect.succeed(42),
|
|
375
381
|
* Effect.succeed("hello"),
|
|
376
|
-
* Effect.fail(new
|
|
382
|
+
* Effect.fail(new OopsError())
|
|
377
383
|
* ]
|
|
378
384
|
* ```
|
|
379
385
|
*/
|
|
@@ -625,7 +631,6 @@ export declare namespace All {
|
|
|
625
631
|
* ```
|
|
626
632
|
*
|
|
627
633
|
* @see {@link forEach} for iterating over elements and applying an effect.
|
|
628
|
-
* @see {@link allWith} for a data-last version of this function.
|
|
629
634
|
*
|
|
630
635
|
* @since 2.0.0
|
|
631
636
|
* @category Collecting
|
|
@@ -724,6 +729,291 @@ export declare const partition: {
|
|
|
724
729
|
readonly concurrency?: Concurrency | undefined;
|
|
725
730
|
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>;
|
|
726
731
|
};
|
|
732
|
+
/**
|
|
733
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
734
|
+
*
|
|
735
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
736
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
737
|
+
* If all effects succeed, it returns all collected successes.
|
|
738
|
+
*
|
|
739
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
740
|
+
* elements.
|
|
741
|
+
*
|
|
742
|
+
* @example
|
|
743
|
+
* ```ts
|
|
744
|
+
* import { Effect } from "effect"
|
|
745
|
+
*
|
|
746
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
747
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
748
|
+
* )
|
|
749
|
+
*
|
|
750
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
751
|
+
* // {
|
|
752
|
+
* // _id: 'Exit',
|
|
753
|
+
* // _tag: 'Failure',
|
|
754
|
+
* // cause: {
|
|
755
|
+
* // _id: 'Cause',
|
|
756
|
+
* // reasons: [
|
|
757
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
758
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
759
|
+
* // ]
|
|
760
|
+
* // }
|
|
761
|
+
* // }
|
|
762
|
+
* ```
|
|
763
|
+
*
|
|
764
|
+
* @since 4.0.0
|
|
765
|
+
* @category Error Accumulation
|
|
766
|
+
*/
|
|
767
|
+
export declare const validate: {
|
|
768
|
+
/**
|
|
769
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
770
|
+
*
|
|
771
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
772
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
773
|
+
* If all effects succeed, it returns all collected successes.
|
|
774
|
+
*
|
|
775
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
776
|
+
* elements.
|
|
777
|
+
*
|
|
778
|
+
* @example
|
|
779
|
+
* ```ts
|
|
780
|
+
* import { Effect } from "effect"
|
|
781
|
+
*
|
|
782
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
783
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
784
|
+
* )
|
|
785
|
+
*
|
|
786
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
787
|
+
* // {
|
|
788
|
+
* // _id: 'Exit',
|
|
789
|
+
* // _tag: 'Failure',
|
|
790
|
+
* // cause: {
|
|
791
|
+
* // _id: 'Cause',
|
|
792
|
+
* // reasons: [
|
|
793
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
794
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
795
|
+
* // ]
|
|
796
|
+
* // }
|
|
797
|
+
* // }
|
|
798
|
+
* ```
|
|
799
|
+
*
|
|
800
|
+
* @since 4.0.0
|
|
801
|
+
* @category Error Accumulation
|
|
802
|
+
*/
|
|
803
|
+
<A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
|
|
804
|
+
readonly concurrency?: Concurrency | undefined;
|
|
805
|
+
readonly discard?: false | undefined;
|
|
806
|
+
} | undefined): (elements: Iterable<A>) => Effect<Array<B>, Arr.NonEmptyArray<E>, R>;
|
|
807
|
+
/**
|
|
808
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
809
|
+
*
|
|
810
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
811
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
812
|
+
* If all effects succeed, it returns all collected successes.
|
|
813
|
+
*
|
|
814
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
815
|
+
* elements.
|
|
816
|
+
*
|
|
817
|
+
* @example
|
|
818
|
+
* ```ts
|
|
819
|
+
* import { Effect } from "effect"
|
|
820
|
+
*
|
|
821
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
822
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
823
|
+
* )
|
|
824
|
+
*
|
|
825
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
826
|
+
* // {
|
|
827
|
+
* // _id: 'Exit',
|
|
828
|
+
* // _tag: 'Failure',
|
|
829
|
+
* // cause: {
|
|
830
|
+
* // _id: 'Cause',
|
|
831
|
+
* // reasons: [
|
|
832
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
833
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
834
|
+
* // ]
|
|
835
|
+
* // }
|
|
836
|
+
* // }
|
|
837
|
+
* ```
|
|
838
|
+
*
|
|
839
|
+
* @since 4.0.0
|
|
840
|
+
* @category Error Accumulation
|
|
841
|
+
*/
|
|
842
|
+
<A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options: {
|
|
843
|
+
readonly concurrency?: Concurrency | undefined;
|
|
844
|
+
readonly discard: true;
|
|
845
|
+
}): (elements: Iterable<A>) => Effect<void, Arr.NonEmptyArray<E>, R>;
|
|
846
|
+
/**
|
|
847
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
848
|
+
*
|
|
849
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
850
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
851
|
+
* If all effects succeed, it returns all collected successes.
|
|
852
|
+
*
|
|
853
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
854
|
+
* elements.
|
|
855
|
+
*
|
|
856
|
+
* @example
|
|
857
|
+
* ```ts
|
|
858
|
+
* import { Effect } from "effect"
|
|
859
|
+
*
|
|
860
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
861
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
862
|
+
* )
|
|
863
|
+
*
|
|
864
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
865
|
+
* // {
|
|
866
|
+
* // _id: 'Exit',
|
|
867
|
+
* // _tag: 'Failure',
|
|
868
|
+
* // cause: {
|
|
869
|
+
* // _id: 'Cause',
|
|
870
|
+
* // reasons: [
|
|
871
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
872
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
873
|
+
* // ]
|
|
874
|
+
* // }
|
|
875
|
+
* // }
|
|
876
|
+
* ```
|
|
877
|
+
*
|
|
878
|
+
* @since 4.0.0
|
|
879
|
+
* @category Error Accumulation
|
|
880
|
+
*/
|
|
881
|
+
<A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
|
|
882
|
+
readonly concurrency?: Concurrency | undefined;
|
|
883
|
+
readonly discard?: false | undefined;
|
|
884
|
+
} | undefined): Effect<Array<B>, Arr.NonEmptyArray<E>, R>;
|
|
885
|
+
/**
|
|
886
|
+
* Applies an effectful function to each element and accumulates all failures.
|
|
887
|
+
*
|
|
888
|
+
* This function always evaluates every element. If at least one effect fails,
|
|
889
|
+
* all failures are returned as a non-empty array and successes are discarded.
|
|
890
|
+
* If all effects succeed, it returns all collected successes.
|
|
891
|
+
*
|
|
892
|
+
* Use `discard: true` to ignore successful values while still validating all
|
|
893
|
+
* elements.
|
|
894
|
+
*
|
|
895
|
+
* @example
|
|
896
|
+
* ```ts
|
|
897
|
+
* import { Effect } from "effect"
|
|
898
|
+
*
|
|
899
|
+
* const program = Effect.validate([0, 1, 2, 3], (n) =>
|
|
900
|
+
* n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
|
|
901
|
+
* )
|
|
902
|
+
*
|
|
903
|
+
* Effect.runPromiseExit(program).then(console.log)
|
|
904
|
+
* // {
|
|
905
|
+
* // _id: 'Exit',
|
|
906
|
+
* // _tag: 'Failure',
|
|
907
|
+
* // cause: {
|
|
908
|
+
* // _id: 'Cause',
|
|
909
|
+
* // reasons: [
|
|
910
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '0 is even' },
|
|
911
|
+
* // { _id: 'Reason', _tag: 'Fail', error: '2 is even' }
|
|
912
|
+
* // ]
|
|
913
|
+
* // }
|
|
914
|
+
* // }
|
|
915
|
+
* ```
|
|
916
|
+
*
|
|
917
|
+
* @since 4.0.0
|
|
918
|
+
* @category Error Accumulation
|
|
919
|
+
*/
|
|
920
|
+
<A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options: {
|
|
921
|
+
readonly concurrency?: Concurrency | undefined;
|
|
922
|
+
readonly discard: true;
|
|
923
|
+
}): Effect<void, Arr.NonEmptyArray<E>, R>;
|
|
924
|
+
};
|
|
925
|
+
/**
|
|
926
|
+
* Returns the first element that satisfies an effectful predicate.
|
|
927
|
+
*
|
|
928
|
+
* The predicate receives the element and its index. Evaluation short-circuits
|
|
929
|
+
* as soon as an element matches.
|
|
930
|
+
*
|
|
931
|
+
* @example
|
|
932
|
+
* ```ts
|
|
933
|
+
* import { Effect } from "effect"
|
|
934
|
+
*
|
|
935
|
+
* const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
|
|
936
|
+
*
|
|
937
|
+
* Effect.runPromise(program).then(console.log)
|
|
938
|
+
* // { _id: 'Option', _tag: 'Some', value: 3 }
|
|
939
|
+
* ```
|
|
940
|
+
*
|
|
941
|
+
* @since 2.0.0
|
|
942
|
+
* @category Collecting
|
|
943
|
+
*/
|
|
944
|
+
export declare const findFirst: {
|
|
945
|
+
/**
|
|
946
|
+
* Returns the first element that satisfies an effectful predicate.
|
|
947
|
+
*
|
|
948
|
+
* The predicate receives the element and its index. Evaluation short-circuits
|
|
949
|
+
* as soon as an element matches.
|
|
950
|
+
*
|
|
951
|
+
* @example
|
|
952
|
+
* ```ts
|
|
953
|
+
* import { Effect } from "effect"
|
|
954
|
+
*
|
|
955
|
+
* const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
|
|
956
|
+
*
|
|
957
|
+
* Effect.runPromise(program).then(console.log)
|
|
958
|
+
* // { _id: 'Option', _tag: 'Some', value: 3 }
|
|
959
|
+
* ```
|
|
960
|
+
*
|
|
961
|
+
* @since 2.0.0
|
|
962
|
+
* @category Collecting
|
|
963
|
+
*/
|
|
964
|
+
<A, E, R>(predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>): (elements: Iterable<A>) => Effect<Option<A>, E, R>;
|
|
965
|
+
/**
|
|
966
|
+
* Returns the first element that satisfies an effectful predicate.
|
|
967
|
+
*
|
|
968
|
+
* The predicate receives the element and its index. Evaluation short-circuits
|
|
969
|
+
* as soon as an element matches.
|
|
970
|
+
*
|
|
971
|
+
* @example
|
|
972
|
+
* ```ts
|
|
973
|
+
* import { Effect } from "effect"
|
|
974
|
+
*
|
|
975
|
+
* const program = Effect.findFirst([1, 2, 3, 4], (n) => Effect.succeed(n > 2))
|
|
976
|
+
*
|
|
977
|
+
* Effect.runPromise(program).then(console.log)
|
|
978
|
+
* // { _id: 'Option', _tag: 'Some', value: 3 }
|
|
979
|
+
* ```
|
|
980
|
+
*
|
|
981
|
+
* @since 2.0.0
|
|
982
|
+
* @category Collecting
|
|
983
|
+
*/
|
|
984
|
+
<A, E, R>(elements: Iterable<A>, predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>): Effect<Option<A>, E, R>;
|
|
985
|
+
};
|
|
986
|
+
/**
|
|
987
|
+
* Returns the first value that passes an effectful `FilterEffect`.
|
|
988
|
+
*
|
|
989
|
+
* The filter receives the element and index. Evaluation short-circuits on the
|
|
990
|
+
* first `Result.succeed` and returns the transformed value in `Option.some`.
|
|
991
|
+
*
|
|
992
|
+
* @since 4.0.0
|
|
993
|
+
* @category Collecting
|
|
994
|
+
*/
|
|
995
|
+
export declare const findFirstFilter: {
|
|
996
|
+
/**
|
|
997
|
+
* Returns the first value that passes an effectful `FilterEffect`.
|
|
998
|
+
*
|
|
999
|
+
* The filter receives the element and index. Evaluation short-circuits on the
|
|
1000
|
+
* first `Result.succeed` and returns the transformed value in `Option.some`.
|
|
1001
|
+
*
|
|
1002
|
+
* @since 4.0.0
|
|
1003
|
+
* @category Collecting
|
|
1004
|
+
*/
|
|
1005
|
+
<A, B, X, E, R>(filter: (input: NoInfer<A>, i: number) => Effect<Result.Result<B, X>, E, R>): (elements: Iterable<A>) => Effect<Option<B>, E, R>;
|
|
1006
|
+
/**
|
|
1007
|
+
* Returns the first value that passes an effectful `FilterEffect`.
|
|
1008
|
+
*
|
|
1009
|
+
* The filter receives the element and index. Evaluation short-circuits on the
|
|
1010
|
+
* first `Result.succeed` and returns the transformed value in `Option.some`.
|
|
1011
|
+
*
|
|
1012
|
+
* @since 4.0.0
|
|
1013
|
+
* @category Collecting
|
|
1014
|
+
*/
|
|
1015
|
+
<A, B, X, E, R>(elements: Iterable<A>, filter: (input: NoInfer<A>, i: number) => Effect<Result.Result<B, X>, E, R>): Effect<Option<B>, E, R>;
|
|
1016
|
+
};
|
|
727
1017
|
/**
|
|
728
1018
|
* Executes an effectful operation for each element in an `Iterable`.
|
|
729
1019
|
*
|
|
@@ -1068,16 +1358,18 @@ export declare const promise: <A>(evaluate: (signal: AbortSignal) => PromiseLike
|
|
|
1068
1358
|
*
|
|
1069
1359
|
* @example Custom Error Handling
|
|
1070
1360
|
* ```ts
|
|
1071
|
-
* import { Effect } from "effect"
|
|
1361
|
+
* import { Data, Effect } from "effect"
|
|
1362
|
+
*
|
|
1363
|
+
* class TodoFetchError extends Data.TaggedError("TodoFetchError")<{ readonly cause: unknown }> {}
|
|
1072
1364
|
*
|
|
1073
1365
|
* const getTodo = (id: number) =>
|
|
1074
1366
|
* Effect.tryPromise({
|
|
1075
1367
|
* try: () => fetch(`https://jsonplaceholder.typicode.com/todos/${id}`),
|
|
1076
1368
|
* // remap the error
|
|
1077
|
-
* catch: (
|
|
1369
|
+
* catch: (cause) => new TodoFetchError({ cause })
|
|
1078
1370
|
* })
|
|
1079
1371
|
*
|
|
1080
|
-
* // ┌─── Effect<Response,
|
|
1372
|
+
* // ┌─── Effect<Response, TodoFetchError, never>
|
|
1081
1373
|
* // ▼
|
|
1082
1374
|
* const program = getTodo(1)
|
|
1083
1375
|
* ```
|
|
@@ -1307,8 +1599,13 @@ undefined_ as undefined };
|
|
|
1307
1599
|
*
|
|
1308
1600
|
* **When to Use**
|
|
1309
1601
|
*
|
|
1310
|
-
* Use `Effect.
|
|
1602
|
+
* Use `Effect.callback` when dealing with APIs that use callback-style instead of
|
|
1311
1603
|
* `async/await` or `Promise`.
|
|
1604
|
+
* * **Previously Known As**
|
|
1605
|
+
*
|
|
1606
|
+
* This API replaces the following from Effect 3.x:
|
|
1607
|
+
*
|
|
1608
|
+
* - `Effect.async`
|
|
1312
1609
|
*
|
|
1313
1610
|
* @example
|
|
1314
1611
|
* ```ts
|
|
@@ -1352,6 +1649,90 @@ export declare const callback: <A, E = never, R = never>(register: (this: Schedu
|
|
|
1352
1649
|
* @category Creating Effects
|
|
1353
1650
|
*/
|
|
1354
1651
|
export declare const never: Effect<never>;
|
|
1652
|
+
/**
|
|
1653
|
+
* An `Effect` containing an empty record `{}`, used as the starting point for
|
|
1654
|
+
* do notation chains.
|
|
1655
|
+
*
|
|
1656
|
+
* @example
|
|
1657
|
+
* ```ts
|
|
1658
|
+
* import { Effect } from "effect"
|
|
1659
|
+
* import { pipe } from "effect/Function"
|
|
1660
|
+
*
|
|
1661
|
+
* const program = pipe(
|
|
1662
|
+
* Effect.Do,
|
|
1663
|
+
* Effect.bind("x", () => Effect.succeed(2)),
|
|
1664
|
+
* Effect.bind("y", ({ x }) => Effect.succeed(x + 1)),
|
|
1665
|
+
* Effect.let("sum", ({ x, y }) => x + y)
|
|
1666
|
+
* )
|
|
1667
|
+
* ```
|
|
1668
|
+
*
|
|
1669
|
+
* @since 4.0.0
|
|
1670
|
+
* @category Do notation
|
|
1671
|
+
*/
|
|
1672
|
+
export declare const Do: Effect<{}>;
|
|
1673
|
+
/**
|
|
1674
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1675
|
+
* record used in do notation pipelines.
|
|
1676
|
+
*
|
|
1677
|
+
* @since 4.0.0
|
|
1678
|
+
* @category Do notation
|
|
1679
|
+
*/
|
|
1680
|
+
export declare const bindTo: {
|
|
1681
|
+
/**
|
|
1682
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1683
|
+
* record used in do notation pipelines.
|
|
1684
|
+
*
|
|
1685
|
+
* @since 4.0.0
|
|
1686
|
+
* @category Do notation
|
|
1687
|
+
*/
|
|
1688
|
+
<N extends string>(name: N): <A, E, R>(self: Effect<A, E, R>) => Effect<{
|
|
1689
|
+
[K in N]: A;
|
|
1690
|
+
}, E, R>;
|
|
1691
|
+
/**
|
|
1692
|
+
* Gives a name to the success value of an `Effect`, creating a single-key
|
|
1693
|
+
* record used in do notation pipelines.
|
|
1694
|
+
*
|
|
1695
|
+
* @since 4.0.0
|
|
1696
|
+
* @category Do notation
|
|
1697
|
+
*/
|
|
1698
|
+
<A, E, R, N extends string>(self: Effect<A, E, R>, name: N): Effect<{
|
|
1699
|
+
[K in N]: A;
|
|
1700
|
+
}, E, R>;
|
|
1701
|
+
};
|
|
1702
|
+
declare const let_: {
|
|
1703
|
+
<N extends string, A extends Record<string, any>, B>(name: N, f: (a: NoInfer<A>) => B): <E, R>(self: Effect<A, E, R>) => Effect<Simplify<Omit<A, N> & Record<N, B>>, E, R>;
|
|
1704
|
+
<A extends Record<string, any>, E, R, B, N extends string>(self: Effect<A, E, R>, name: N, f: (a: NoInfer<A>) => B): Effect<Simplify<Omit<A, N> & Record<N, B>>, E, R>;
|
|
1705
|
+
};
|
|
1706
|
+
export {
|
|
1707
|
+
/**
|
|
1708
|
+
* Adds a computed plain value to the do notation record.
|
|
1709
|
+
*
|
|
1710
|
+
* @since 4.0.0
|
|
1711
|
+
* @category Do notation
|
|
1712
|
+
*/
|
|
1713
|
+
let_ as let };
|
|
1714
|
+
/**
|
|
1715
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1716
|
+
*
|
|
1717
|
+
* @since 4.0.0
|
|
1718
|
+
* @category Do notation
|
|
1719
|
+
*/
|
|
1720
|
+
export declare const bind: {
|
|
1721
|
+
/**
|
|
1722
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1723
|
+
*
|
|
1724
|
+
* @since 4.0.0
|
|
1725
|
+
* @category Do notation
|
|
1726
|
+
*/
|
|
1727
|
+
<N extends string, A extends Record<string, any>, B, E2, R2>(name: N, f: (a: NoInfer<A>) => Effect<B, E2, R2>): <E, R>(self: Effect<A, E, R>) => Effect<Simplify<Omit<A, N> & Record<N, B>>, E | E2, R | R2>;
|
|
1728
|
+
/**
|
|
1729
|
+
* Adds an `Effect` value to the do notation record under a given name.
|
|
1730
|
+
*
|
|
1731
|
+
* @since 4.0.0
|
|
1732
|
+
* @category Do notation
|
|
1733
|
+
*/
|
|
1734
|
+
<A extends Record<string, any>, E, R, B, E2, R2, N extends string>(self: Effect<A, E, R>, name: N, f: (a: NoInfer<A>) => Effect<B, E2, R2>): Effect<Simplify<Omit<A, N> & Record<N, B>>, E | E2, R | R2>;
|
|
1735
|
+
};
|
|
1355
1736
|
/**
|
|
1356
1737
|
* Provides a way to write effectful code using generator functions, simplifying
|
|
1357
1738
|
* control flow and error handling.
|
|
@@ -1369,16 +1750,18 @@ export declare const never: Effect<never>;
|
|
|
1369
1750
|
*
|
|
1370
1751
|
* @example
|
|
1371
1752
|
* ```ts
|
|
1372
|
-
* import { Effect } from "effect"
|
|
1753
|
+
* import { Data, Effect } from "effect"
|
|
1754
|
+
*
|
|
1755
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1373
1756
|
*
|
|
1374
1757
|
* const addServiceCharge = (amount: number) => amount + 1
|
|
1375
1758
|
*
|
|
1376
1759
|
* const applyDiscount = (
|
|
1377
1760
|
* total: number,
|
|
1378
1761
|
* discountRate: number
|
|
1379
|
-
* ): Effect.Effect<number,
|
|
1762
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1380
1763
|
* discountRate === 0
|
|
1381
|
-
* ? Effect.fail(new
|
|
1764
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1382
1765
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1383
1766
|
*
|
|
1384
1767
|
* const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
|
|
@@ -1418,16 +1801,18 @@ export declare const gen: {
|
|
|
1418
1801
|
*
|
|
1419
1802
|
* @example
|
|
1420
1803
|
* ```ts
|
|
1421
|
-
* import { Effect } from "effect"
|
|
1804
|
+
* import { Data, Effect } from "effect"
|
|
1805
|
+
*
|
|
1806
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1422
1807
|
*
|
|
1423
1808
|
* const addServiceCharge = (amount: number) => amount + 1
|
|
1424
1809
|
*
|
|
1425
1810
|
* const applyDiscount = (
|
|
1426
1811
|
* total: number,
|
|
1427
1812
|
* discountRate: number
|
|
1428
|
-
* ): Effect.Effect<number,
|
|
1813
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1429
1814
|
* discountRate === 0
|
|
1430
|
-
* ? Effect.fail(new
|
|
1815
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1431
1816
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1432
1817
|
*
|
|
1433
1818
|
* const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
|
|
@@ -1471,16 +1856,18 @@ export declare const gen: {
|
|
|
1471
1856
|
*
|
|
1472
1857
|
* @example
|
|
1473
1858
|
* ```ts
|
|
1474
|
-
* import { Effect } from "effect"
|
|
1859
|
+
* import { Data, Effect } from "effect"
|
|
1860
|
+
*
|
|
1861
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1475
1862
|
*
|
|
1476
1863
|
* const addServiceCharge = (amount: number) => amount + 1
|
|
1477
1864
|
*
|
|
1478
1865
|
* const applyDiscount = (
|
|
1479
1866
|
* total: number,
|
|
1480
1867
|
* discountRate: number
|
|
1481
|
-
* ): Effect.Effect<number,
|
|
1868
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1482
1869
|
* discountRate === 0
|
|
1483
|
-
* ? Effect.fail(new
|
|
1870
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1484
1871
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1485
1872
|
*
|
|
1486
1873
|
* const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
|
|
@@ -1535,12 +1922,14 @@ export declare namespace gen {
|
|
|
1535
1922
|
* @example
|
|
1536
1923
|
* ```ts
|
|
1537
1924
|
* // Title: Creating a Failed Effect
|
|
1538
|
-
* import { Effect } from "effect"
|
|
1925
|
+
* import { Data, Effect } from "effect"
|
|
1926
|
+
*
|
|
1927
|
+
* class OperationFailedError extends Data.TaggedError("OperationFailedError")<{}> {}
|
|
1539
1928
|
*
|
|
1540
|
-
* // ┌─── Effect<never,
|
|
1929
|
+
* // ┌─── Effect<never, OperationFailedError, never>
|
|
1541
1930
|
* // ▼
|
|
1542
1931
|
* const failure = Effect.fail(
|
|
1543
|
-
* new
|
|
1932
|
+
* new OperationFailedError()
|
|
1544
1933
|
* )
|
|
1545
1934
|
* ```
|
|
1546
1935
|
*
|
|
@@ -1556,9 +1945,11 @@ export declare const fail: <E>(error: E) => Effect<never, E>;
|
|
|
1556
1945
|
*
|
|
1557
1946
|
* @example
|
|
1558
1947
|
* ```ts
|
|
1559
|
-
* import { Effect } from "effect"
|
|
1948
|
+
* import { Data, Effect } from "effect"
|
|
1560
1949
|
*
|
|
1561
|
-
*
|
|
1950
|
+
* class ProgramError extends Data.TaggedError("ProgramError")<{ readonly failedAt: Date }> {}
|
|
1951
|
+
*
|
|
1952
|
+
* const program = Effect.failSync(() => new ProgramError({ failedAt: new Date() }))
|
|
1562
1953
|
*
|
|
1563
1954
|
* Effect.runPromiseExit(program).then(console.log)
|
|
1564
1955
|
* // Output: { _id: 'Exit', _tag: 'Failure', cause: ... }
|
|
@@ -1705,12 +2096,14 @@ export {
|
|
|
1705
2096
|
*
|
|
1706
2097
|
* @example Custom Error Handling
|
|
1707
2098
|
* ```ts
|
|
1708
|
-
* import { Effect } from "effect"
|
|
2099
|
+
* import { Data, Effect } from "effect"
|
|
2100
|
+
*
|
|
2101
|
+
* class JsonParsingError extends Data.TaggedError("JsonParsingError")<{ readonly cause: unknown }> {}
|
|
1709
2102
|
*
|
|
1710
2103
|
* const parseJSON = (input: string) =>
|
|
1711
2104
|
* Effect.try({
|
|
1712
2105
|
* try: () => JSON.parse(input),
|
|
1713
|
-
* catch: (
|
|
2106
|
+
* catch: (cause) => new JsonParsingError({ cause })
|
|
1714
2107
|
* })
|
|
1715
2108
|
*
|
|
1716
2109
|
* Effect.runPromiseExit(parseJSON("invalid json")).then(console.log)
|
|
@@ -1832,17 +2225,17 @@ export declare const fromOption: <A>(option: Option<A>) => Effect<A, Cause.NoSuc
|
|
|
1832
2225
|
* ```ts
|
|
1833
2226
|
* import { Console, Effect } from "effect"
|
|
1834
2227
|
*
|
|
1835
|
-
* const input: string | null
|
|
1836
|
-
*
|
|
1837
|
-
* const program = Effect.gen(function*() {
|
|
2228
|
+
* const program = Effect.fn(function*(input: string | null) {
|
|
1838
2229
|
* const value = yield* Effect.fromNullishOr(input)
|
|
1839
2230
|
* yield* Console.log(value)
|
|
1840
|
-
* }
|
|
2231
|
+
* },
|
|
1841
2232
|
* Effect.catch(() => Console.log("missing"))
|
|
1842
2233
|
* )
|
|
1843
2234
|
*
|
|
1844
|
-
* Effect.runPromise(program)
|
|
2235
|
+
* Effect.runPromise(program(null))
|
|
1845
2236
|
* // Output: missing
|
|
2237
|
+
* Effect.runPromise(program("hello"))
|
|
2238
|
+
* // Output: hello
|
|
1846
2239
|
* ```
|
|
1847
2240
|
*
|
|
1848
2241
|
* @since 4.0.0
|
|
@@ -1903,15 +2296,17 @@ export declare const fromYieldable: <Self extends Yieldable.Any, A, E, R>(yielda
|
|
|
1903
2296
|
*
|
|
1904
2297
|
* @example
|
|
1905
2298
|
* ```ts
|
|
1906
|
-
* import { Effect, pipe } from "effect"
|
|
2299
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2300
|
+
*
|
|
2301
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1907
2302
|
*
|
|
1908
2303
|
* // Function to apply a discount safely to a transaction amount
|
|
1909
2304
|
* const applyDiscount = (
|
|
1910
2305
|
* total: number,
|
|
1911
2306
|
* discountRate: number
|
|
1912
|
-
* ): Effect.Effect<number,
|
|
2307
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1913
2308
|
* discountRate === 0
|
|
1914
|
-
* ? Effect.fail(new
|
|
2309
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1915
2310
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1916
2311
|
*
|
|
1917
2312
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -1965,15 +2360,17 @@ export declare const flatMap: {
|
|
|
1965
2360
|
*
|
|
1966
2361
|
* @example
|
|
1967
2362
|
* ```ts
|
|
1968
|
-
* import { Effect, pipe } from "effect"
|
|
2363
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2364
|
+
*
|
|
2365
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1969
2366
|
*
|
|
1970
2367
|
* // Function to apply a discount safely to a transaction amount
|
|
1971
2368
|
* const applyDiscount = (
|
|
1972
2369
|
* total: number,
|
|
1973
2370
|
* discountRate: number
|
|
1974
|
-
* ): Effect.Effect<number,
|
|
2371
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1975
2372
|
* discountRate === 0
|
|
1976
|
-
* ? Effect.fail(new
|
|
2373
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1977
2374
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1978
2375
|
*
|
|
1979
2376
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2027,15 +2424,17 @@ export declare const flatMap: {
|
|
|
2027
2424
|
*
|
|
2028
2425
|
* @example
|
|
2029
2426
|
* ```ts
|
|
2030
|
-
* import { Effect, pipe } from "effect"
|
|
2427
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2428
|
+
*
|
|
2429
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2031
2430
|
*
|
|
2032
2431
|
* // Function to apply a discount safely to a transaction amount
|
|
2033
2432
|
* const applyDiscount = (
|
|
2034
2433
|
* total: number,
|
|
2035
2434
|
* discountRate: number
|
|
2036
|
-
* ): Effect.Effect<number,
|
|
2435
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2037
2436
|
* discountRate === 0
|
|
2038
|
-
* ? Effect.fail(new
|
|
2437
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2039
2438
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2040
2439
|
*
|
|
2041
2440
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2120,15 +2519,17 @@ export declare const flatten: <A, E, R, E2, R2>(self: Effect<Effect<A, E, R>, E2
|
|
|
2120
2519
|
*
|
|
2121
2520
|
* @example Applying a Discount Based on Fetched Amount
|
|
2122
2521
|
* ```ts
|
|
2123
|
-
* import { Effect, pipe } from "effect"
|
|
2522
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2523
|
+
*
|
|
2524
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2124
2525
|
*
|
|
2125
2526
|
* // Function to apply a discount safely to a transaction amount
|
|
2126
2527
|
* const applyDiscount = (
|
|
2127
2528
|
* total: number,
|
|
2128
2529
|
* discountRate: number
|
|
2129
|
-
* ): Effect.Effect<number,
|
|
2530
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2130
2531
|
* discountRate === 0
|
|
2131
|
-
* ? Effect.fail(new
|
|
2532
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2132
2533
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2133
2534
|
*
|
|
2134
2535
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2201,15 +2602,17 @@ export declare const andThen: {
|
|
|
2201
2602
|
*
|
|
2202
2603
|
* @example Applying a Discount Based on Fetched Amount
|
|
2203
2604
|
* ```ts
|
|
2204
|
-
* import { Effect, pipe } from "effect"
|
|
2605
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2606
|
+
*
|
|
2607
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2205
2608
|
*
|
|
2206
2609
|
* // Function to apply a discount safely to a transaction amount
|
|
2207
2610
|
* const applyDiscount = (
|
|
2208
2611
|
* total: number,
|
|
2209
2612
|
* discountRate: number
|
|
2210
|
-
* ): Effect.Effect<number,
|
|
2613
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2211
2614
|
* discountRate === 0
|
|
2212
|
-
* ? Effect.fail(new
|
|
2615
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2213
2616
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2214
2617
|
*
|
|
2215
2618
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2282,15 +2685,17 @@ export declare const andThen: {
|
|
|
2282
2685
|
*
|
|
2283
2686
|
* @example Applying a Discount Based on Fetched Amount
|
|
2284
2687
|
* ```ts
|
|
2285
|
-
* import { Effect, pipe } from "effect"
|
|
2688
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2689
|
+
*
|
|
2690
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2286
2691
|
*
|
|
2287
2692
|
* // Function to apply a discount safely to a transaction amount
|
|
2288
2693
|
* const applyDiscount = (
|
|
2289
2694
|
* total: number,
|
|
2290
2695
|
* discountRate: number
|
|
2291
|
-
* ): Effect.Effect<number,
|
|
2696
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2292
2697
|
* discountRate === 0
|
|
2293
|
-
* ? Effect.fail(new
|
|
2698
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2294
2699
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2295
2700
|
*
|
|
2296
2701
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2363,15 +2768,17 @@ export declare const andThen: {
|
|
|
2363
2768
|
*
|
|
2364
2769
|
* @example Applying a Discount Based on Fetched Amount
|
|
2365
2770
|
* ```ts
|
|
2366
|
-
* import { Effect, pipe } from "effect"
|
|
2771
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2772
|
+
*
|
|
2773
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2367
2774
|
*
|
|
2368
2775
|
* // Function to apply a discount safely to a transaction amount
|
|
2369
2776
|
* const applyDiscount = (
|
|
2370
2777
|
* total: number,
|
|
2371
2778
|
* discountRate: number
|
|
2372
|
-
* ): Effect.Effect<number,
|
|
2779
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2373
2780
|
* discountRate === 0
|
|
2374
|
-
* ? Effect.fail(new
|
|
2781
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2375
2782
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2376
2783
|
*
|
|
2377
2784
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2444,15 +2851,17 @@ export declare const andThen: {
|
|
|
2444
2851
|
*
|
|
2445
2852
|
* @example Applying a Discount Based on Fetched Amount
|
|
2446
2853
|
* ```ts
|
|
2447
|
-
* import { Effect, pipe } from "effect"
|
|
2854
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2855
|
+
*
|
|
2856
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2448
2857
|
*
|
|
2449
2858
|
* // Function to apply a discount safely to a transaction amount
|
|
2450
2859
|
* const applyDiscount = (
|
|
2451
2860
|
* total: number,
|
|
2452
2861
|
* discountRate: number
|
|
2453
|
-
* ): Effect.Effect<number,
|
|
2862
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2454
2863
|
* discountRate === 0
|
|
2455
|
-
* ? Effect.fail(new
|
|
2864
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2456
2865
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2457
2866
|
*
|
|
2458
2867
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2510,16 +2919,18 @@ export declare const andThen: {
|
|
|
2510
2919
|
* @example
|
|
2511
2920
|
* ```ts
|
|
2512
2921
|
* // Title: Logging a step in a pipeline
|
|
2513
|
-
* import { Effect, pipe } from "effect"
|
|
2922
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2514
2923
|
* import { Console } from "effect"
|
|
2515
2924
|
*
|
|
2925
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2926
|
+
*
|
|
2516
2927
|
* // Function to apply a discount safely to a transaction amount
|
|
2517
2928
|
* const applyDiscount = (
|
|
2518
2929
|
* total: number,
|
|
2519
2930
|
* discountRate: number
|
|
2520
|
-
* ): Effect.Effect<number,
|
|
2931
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2521
2932
|
* discountRate === 0
|
|
2522
|
-
* ? Effect.fail(new
|
|
2933
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2523
2934
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2524
2935
|
*
|
|
2525
2936
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2569,16 +2980,18 @@ export declare const tap: {
|
|
|
2569
2980
|
* @example
|
|
2570
2981
|
* ```ts
|
|
2571
2982
|
* // Title: Logging a step in a pipeline
|
|
2572
|
-
* import { Effect, pipe } from "effect"
|
|
2983
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2573
2984
|
* import { Console } from "effect"
|
|
2574
2985
|
*
|
|
2986
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2987
|
+
*
|
|
2575
2988
|
* // Function to apply a discount safely to a transaction amount
|
|
2576
2989
|
* const applyDiscount = (
|
|
2577
2990
|
* total: number,
|
|
2578
2991
|
* discountRate: number
|
|
2579
|
-
* ): Effect.Effect<number,
|
|
2992
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2580
2993
|
* discountRate === 0
|
|
2581
|
-
* ? Effect.fail(new
|
|
2994
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2582
2995
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2583
2996
|
*
|
|
2584
2997
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2628,16 +3041,18 @@ export declare const tap: {
|
|
|
2628
3041
|
* @example
|
|
2629
3042
|
* ```ts
|
|
2630
3043
|
* // Title: Logging a step in a pipeline
|
|
2631
|
-
* import { Effect, pipe } from "effect"
|
|
3044
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2632
3045
|
* import { Console } from "effect"
|
|
2633
3046
|
*
|
|
3047
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3048
|
+
*
|
|
2634
3049
|
* // Function to apply a discount safely to a transaction amount
|
|
2635
3050
|
* const applyDiscount = (
|
|
2636
3051
|
* total: number,
|
|
2637
3052
|
* discountRate: number
|
|
2638
|
-
* ): Effect.Effect<number,
|
|
3053
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2639
3054
|
* discountRate === 0
|
|
2640
|
-
* ? Effect.fail(new
|
|
3055
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2641
3056
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2642
3057
|
*
|
|
2643
3058
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2687,16 +3102,18 @@ export declare const tap: {
|
|
|
2687
3102
|
* @example
|
|
2688
3103
|
* ```ts
|
|
2689
3104
|
* // Title: Logging a step in a pipeline
|
|
2690
|
-
* import { Effect, pipe } from "effect"
|
|
3105
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2691
3106
|
* import { Console } from "effect"
|
|
2692
3107
|
*
|
|
3108
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3109
|
+
*
|
|
2693
3110
|
* // Function to apply a discount safely to a transaction amount
|
|
2694
3111
|
* const applyDiscount = (
|
|
2695
3112
|
* total: number,
|
|
2696
3113
|
* discountRate: number
|
|
2697
|
-
* ): Effect.Effect<number,
|
|
3114
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2698
3115
|
* discountRate === 0
|
|
2699
|
-
* ? Effect.fail(new
|
|
3116
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2700
3117
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2701
3118
|
*
|
|
2702
3119
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2746,16 +3163,18 @@ export declare const tap: {
|
|
|
2746
3163
|
* @example
|
|
2747
3164
|
* ```ts
|
|
2748
3165
|
* // Title: Logging a step in a pipeline
|
|
2749
|
-
* import { Effect, pipe } from "effect"
|
|
3166
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2750
3167
|
* import { Console } from "effect"
|
|
2751
3168
|
*
|
|
3169
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3170
|
+
*
|
|
2752
3171
|
* // Function to apply a discount safely to a transaction amount
|
|
2753
3172
|
* const applyDiscount = (
|
|
2754
3173
|
* total: number,
|
|
2755
3174
|
* discountRate: number
|
|
2756
|
-
* ): Effect.Effect<number,
|
|
3175
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2757
3176
|
* discountRate === 0
|
|
2758
|
-
* ? Effect.fail(new
|
|
3177
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2759
3178
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2760
3179
|
*
|
|
2761
3180
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -3691,7 +4110,8 @@ export declare const catchTag: {
|
|
|
3691
4110
|
* once. Instead of using {@link catchTag} multiple times, you can pass an
|
|
3692
4111
|
* object where each key is an error type's `_tag`, and the value is the handler
|
|
3693
4112
|
* for that specific error. This allows you to catch and recover from multiple
|
|
3694
|
-
* error types in a single call.
|
|
4113
|
+
* error types in a single call. You can also provide a fallback handler for
|
|
4114
|
+
* unhandled errors.
|
|
3695
4115
|
*
|
|
3696
4116
|
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
3697
4117
|
* field is used to identify and match errors.
|
|
@@ -3733,7 +4153,8 @@ export declare const catchTags: {
|
|
|
3733
4153
|
* once. Instead of using {@link catchTag} multiple times, you can pass an
|
|
3734
4154
|
* object where each key is an error type's `_tag`, and the value is the handler
|
|
3735
4155
|
* for that specific error. This allows you to catch and recover from multiple
|
|
3736
|
-
* error types in a single call.
|
|
4156
|
+
* error types in a single call. You can also provide a fallback handler for
|
|
4157
|
+
* unhandled errors.
|
|
3737
4158
|
*
|
|
3738
4159
|
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
3739
4160
|
* field is used to identify and match errors.
|
|
@@ -3775,13 +4196,15 @@ export declare const catchTags: {
|
|
|
3775
4196
|
[K in Exclude<keyof Cases, Extract<E, {
|
|
3776
4197
|
_tag: string;
|
|
3777
4198
|
}>["_tag"]>]: never;
|
|
3778
|
-
})
|
|
3779
|
-
|
|
3780
|
-
}
|
|
4199
|
+
}), A2 = never, E2 = Exclude<E, {
|
|
4200
|
+
_tag: keyof Cases;
|
|
4201
|
+
}>, R2 = never>(cases: Cases, orElse?: ((e: Exclude<E, {
|
|
3781
4202
|
_tag: keyof Cases;
|
|
3782
|
-
}> | {
|
|
4203
|
+
}>) => Effect<A2, E2, R2>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | {
|
|
4204
|
+
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
|
|
4205
|
+
}[keyof Cases], E2 | {
|
|
3783
4206
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
|
|
3784
|
-
}[keyof Cases], R | {
|
|
4207
|
+
}[keyof Cases], R | R2 | {
|
|
3785
4208
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, any, infer R> ? R : never;
|
|
3786
4209
|
}[keyof Cases]>;
|
|
3787
4210
|
/**
|
|
@@ -3793,7 +4216,8 @@ export declare const catchTags: {
|
|
|
3793
4216
|
* once. Instead of using {@link catchTag} multiple times, you can pass an
|
|
3794
4217
|
* object where each key is an error type's `_tag`, and the value is the handler
|
|
3795
4218
|
* for that specific error. This allows you to catch and recover from multiple
|
|
3796
|
-
* error types in a single call.
|
|
4219
|
+
* error types in a single call. You can also provide a fallback handler for
|
|
4220
|
+
* unhandled errors.
|
|
3797
4221
|
*
|
|
3798
4222
|
* The error type must have a readonly `_tag` field to use `catchTag`. This
|
|
3799
4223
|
* field is used to identify and match errors.
|
|
@@ -3835,13 +4259,15 @@ export declare const catchTags: {
|
|
|
3835
4259
|
[K in Exclude<keyof Cases, Extract<E, {
|
|
3836
4260
|
_tag: string;
|
|
3837
4261
|
}>["_tag"]>]: never;
|
|
3838
|
-
})
|
|
3839
|
-
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
|
|
3840
|
-
}[keyof Cases], Exclude<E, {
|
|
4262
|
+
}), A2 = never, E2 = Exclude<E, {
|
|
3841
4263
|
_tag: keyof Cases;
|
|
3842
|
-
}>
|
|
4264
|
+
}>, R2 = never>(self: Effect<A, E, R>, cases: Cases, orElse?: ((e: Exclude<E, {
|
|
4265
|
+
_tag: keyof Cases;
|
|
4266
|
+
}>) => Effect<A2, E2, R2>) | undefined): Effect<A | A2 | {
|
|
4267
|
+
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
|
|
4268
|
+
}[keyof Cases], E2 | {
|
|
3843
4269
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
|
|
3844
|
-
}[keyof Cases], R | {
|
|
4270
|
+
}[keyof Cases], R | R2 | {
|
|
3845
4271
|
[K in keyof Cases]: Cases[K] extends (...args: Array<any>) => Effect<any, any, infer R> ? R : never;
|
|
3846
4272
|
}[keyof Cases]>;
|
|
3847
4273
|
};
|
|
@@ -3916,7 +4342,7 @@ export declare const catchReason: {
|
|
|
3916
4342
|
* @since 4.0.0
|
|
3917
4343
|
* @category Error Handling
|
|
3918
4344
|
*/
|
|
3919
|
-
<K extends Tags<E>, E, RK extends ReasonTags<ExtractTag<NoInfer<E>, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>;
|
|
4345
|
+
<K extends Tags<E>, E, RK extends ReasonTags<ExtractTag<NoInfer<E>, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>, error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<NoInfer<E>, K>, RK>, error: OmitReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>;
|
|
3920
4346
|
/**
|
|
3921
4347
|
* Catches a specific reason within a tagged error.
|
|
3922
4348
|
*
|
|
@@ -3952,7 +4378,7 @@ export declare const catchReason: {
|
|
|
3952
4378
|
* @since 4.0.0
|
|
3953
4379
|
* @category Error Handling
|
|
3954
4380
|
*/
|
|
3955
|
-
<A, E, R, K extends Tags<E>, RK extends ReasonTags<ExtractTag<E, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(self: Effect<A, E, R>, errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<E, K>, RK>) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>;
|
|
4381
|
+
<A, E, R, K extends Tags<E>, RK extends ReasonTags<ExtractTag<E, K>>, A2, E2, R2, A3 = unassigned, E3 = never, R3 = never>(self: Effect<A, E, R>, errorTag: K, reasonTag: RK, f: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Effect<A2, E2, R2>, orElse?: ((reasons: ExcludeReason<ExtractTag<E, K>, RK>, error: OmitReason<ExtractTag<E, K>, RK>) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | Exclude<A3, unassigned>, (A3 extends unassigned ? E : ExcludeTag<E, K>) | E2 | E3, R | R2 | R3>;
|
|
3956
4382
|
};
|
|
3957
4383
|
/**
|
|
3958
4384
|
* Catches multiple reasons within a tagged error using an object of handlers.
|
|
@@ -4024,8 +4450,8 @@ export declare const catchReasons: {
|
|
|
4024
4450
|
* @category Error Handling
|
|
4025
4451
|
*/
|
|
4026
4452
|
<K extends Tags<E>, E, Cases extends {
|
|
4027
|
-
[RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<any, any, any>;
|
|
4028
|
-
}, A2 = unassigned, E2 = never, R2 = never>(errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | Exclude<A2, unassigned> | {
|
|
4453
|
+
[RK in ReasonTags<ExtractTag<NoInfer<E>, K>>]+?: (reason: ExtractReason<ExtractTag<NoInfer<E>, K>, RK>, error: NarrowReason<ExtractTag<NoInfer<E>, K>, RK>) => Effect<any, any, any>;
|
|
4454
|
+
}, A2 = unassigned, E2 = never, R2 = never>(errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>, error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | Exclude<A2, unassigned> | {
|
|
4029
4455
|
[RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
|
|
4030
4456
|
}[keyof Cases], (A2 extends unassigned ? E : ExcludeTag<E, K>) | E2 | {
|
|
4031
4457
|
[RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
|
|
@@ -4067,8 +4493,8 @@ export declare const catchReasons: {
|
|
|
4067
4493
|
* @category Error Handling
|
|
4068
4494
|
*/
|
|
4069
4495
|
<A, E, R, K extends Tags<E>, Cases extends {
|
|
4070
|
-
[RK in ReasonTags<ExtractTag<E, K>>]+?: (reason: ExtractReason<ExtractTag<E, K>, RK>) => Effect<any, any, any>;
|
|
4071
|
-
}, A2 = unassigned, E2 = never, R2 = never>(self: Effect<A, E, R>, errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): Effect<A | Exclude<A2, unassigned> | {
|
|
4496
|
+
[RK in ReasonTags<ExtractTag<E, K>>]+?: (reason: ExtractReason<ExtractTag<E, K>, RK>, error: NarrowReason<ExtractTag<E, K>, RK>) => Effect<any, any, any>;
|
|
4497
|
+
}, A2 = unassigned, E2 = never, R2 = never>(self: Effect<A, E, R>, errorTag: K, cases: Cases, orElse?: ((reason: ExcludeReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>, error: OmitReason<ExtractTag<NoInfer<E>, K>, Extract<keyof Cases, string>>) => Effect<A2, E2, R2>) | undefined): Effect<A | Exclude<A2, unassigned> | {
|
|
4072
4498
|
[RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<infer A, any, any> ? A : never;
|
|
4073
4499
|
}[keyof Cases], (A2 extends unassigned ? E : ExcludeTag<E, K>) | E2 | {
|
|
4074
4500
|
[RK in keyof Cases]: Cases[RK] extends (...args: Array<any>) => Effect<any, infer E, any> ? E : never;
|
|
@@ -4469,15 +4895,14 @@ export declare const catchDefect: {
|
|
|
4469
4895
|
<A, E, R, A2, E2, R2>(self: Effect<A, E, R>, f: (defect: unknown) => Effect<A2, E2, R2>): Effect<A | A2, E | E2, R | R2>;
|
|
4470
4896
|
};
|
|
4471
4897
|
/**
|
|
4472
|
-
* Recovers from specific errors using a `
|
|
4473
|
-
* `Refinement`.
|
|
4898
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4474
4899
|
*
|
|
4475
4900
|
* **When to Use**
|
|
4476
4901
|
*
|
|
4477
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4478
|
-
* `
|
|
4479
|
-
*
|
|
4480
|
-
*
|
|
4902
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
4903
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
4904
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
4905
|
+
* interrupts are not caught.
|
|
4481
4906
|
*
|
|
4482
4907
|
* **Previously Known As**
|
|
4483
4908
|
*
|
|
@@ -4504,7 +4929,7 @@ export declare const catchDefect: {
|
|
|
4504
4929
|
*
|
|
4505
4930
|
* // With a Filter
|
|
4506
4931
|
* const recovered2 = program.pipe(
|
|
4507
|
-
* Effect.
|
|
4932
|
+
* Effect.catchFilter(
|
|
4508
4933
|
* Filter.tagged("NotFound"),
|
|
4509
4934
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4510
4935
|
* )
|
|
@@ -4516,15 +4941,14 @@ export declare const catchDefect: {
|
|
|
4516
4941
|
*/
|
|
4517
4942
|
export declare const catchIf: {
|
|
4518
4943
|
/**
|
|
4519
|
-
* Recovers from specific errors using a `
|
|
4520
|
-
* `Refinement`.
|
|
4944
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4521
4945
|
*
|
|
4522
4946
|
* **When to Use**
|
|
4523
4947
|
*
|
|
4524
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4525
|
-
* `
|
|
4526
|
-
*
|
|
4527
|
-
*
|
|
4948
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
4949
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
4950
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
4951
|
+
* interrupts are not caught.
|
|
4528
4952
|
*
|
|
4529
4953
|
* **Previously Known As**
|
|
4530
4954
|
*
|
|
@@ -4551,7 +4975,7 @@ export declare const catchIf: {
|
|
|
4551
4975
|
*
|
|
4552
4976
|
* // With a Filter
|
|
4553
4977
|
* const recovered2 = program.pipe(
|
|
4554
|
-
* Effect.
|
|
4978
|
+
* Effect.catchFilter(
|
|
4555
4979
|
* Filter.tagged("NotFound"),
|
|
4556
4980
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4557
4981
|
* )
|
|
@@ -4563,15 +4987,14 @@ export declare const catchIf: {
|
|
|
4563
4987
|
*/
|
|
4564
4988
|
<E, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(refinement: Predicate.Refinement<NoInfer<E>, EB>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4565
4989
|
/**
|
|
4566
|
-
* Recovers from specific errors using a `
|
|
4567
|
-
* `Refinement`.
|
|
4990
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4568
4991
|
*
|
|
4569
4992
|
* **When to Use**
|
|
4570
4993
|
*
|
|
4571
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4572
|
-
* `
|
|
4573
|
-
*
|
|
4574
|
-
*
|
|
4994
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
4995
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
4996
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
4997
|
+
* interrupts are not caught.
|
|
4575
4998
|
*
|
|
4576
4999
|
* **Previously Known As**
|
|
4577
5000
|
*
|
|
@@ -4598,7 +5021,7 @@ export declare const catchIf: {
|
|
|
4598
5021
|
*
|
|
4599
5022
|
* // With a Filter
|
|
4600
5023
|
* const recovered2 = program.pipe(
|
|
4601
|
-
* Effect.
|
|
5024
|
+
* Effect.catchFilter(
|
|
4602
5025
|
* Filter.tagged("NotFound"),
|
|
4603
5026
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4604
5027
|
* )
|
|
@@ -4608,17 +5031,16 @@ export declare const catchIf: {
|
|
|
4608
5031
|
* @since 2.0.0
|
|
4609
5032
|
* @category Error Handling
|
|
4610
5033
|
*/
|
|
4611
|
-
<E,
|
|
5034
|
+
<E, A2, E2, R2, A3 = never, E3 = E, R3 = never>(predicate: Predicate.Predicate<NoInfer<E>>, f: (e: NoInfer<E>) => Effect<A2, E2, R2>, orElse?: ((e: NoInfer<E>) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4612
5035
|
/**
|
|
4613
|
-
* Recovers from specific errors using a `
|
|
4614
|
-
* `Refinement`.
|
|
5036
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4615
5037
|
*
|
|
4616
5038
|
* **When to Use**
|
|
4617
5039
|
*
|
|
4618
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4619
|
-
* `
|
|
4620
|
-
*
|
|
4621
|
-
*
|
|
5040
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5041
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5042
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5043
|
+
* interrupts are not caught.
|
|
4622
5044
|
*
|
|
4623
5045
|
* **Previously Known As**
|
|
4624
5046
|
*
|
|
@@ -4645,7 +5067,7 @@ export declare const catchIf: {
|
|
|
4645
5067
|
*
|
|
4646
5068
|
* // With a Filter
|
|
4647
5069
|
* const recovered2 = program.pipe(
|
|
4648
|
-
* Effect.
|
|
5070
|
+
* Effect.catchFilter(
|
|
4649
5071
|
* Filter.tagged("NotFound"),
|
|
4650
5072
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4651
5073
|
* )
|
|
@@ -4657,15 +5079,14 @@ export declare const catchIf: {
|
|
|
4657
5079
|
*/
|
|
4658
5080
|
<A, E, R, EB extends E, A2, E2, R2, A3 = never, E3 = Exclude<E, EB>, R3 = never>(self: Effect<A, E, R>, refinement: Predicate.Refinement<E, EB>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: Exclude<E, EB>) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4659
5081
|
/**
|
|
4660
|
-
* Recovers from specific errors using a `
|
|
4661
|
-
* `Refinement`.
|
|
5082
|
+
* Recovers from specific errors using a `Predicate` or `Refinement`.
|
|
4662
5083
|
*
|
|
4663
5084
|
* **When to Use**
|
|
4664
5085
|
*
|
|
4665
|
-
* `catchIf` lets you recover from errors that match a condition.
|
|
4666
|
-
* `
|
|
4667
|
-
*
|
|
4668
|
-
*
|
|
5086
|
+
* `catchIf` lets you recover from errors that match a condition. Use a
|
|
5087
|
+
* `Refinement` for type narrowing or a `Predicate` for simple boolean
|
|
5088
|
+
* matching. Non-matching errors re-fail with the original cause. Defects and
|
|
5089
|
+
* interrupts are not caught.
|
|
4669
5090
|
*
|
|
4670
5091
|
* **Previously Known As**
|
|
4671
5092
|
*
|
|
@@ -4692,7 +5113,7 @@ export declare const catchIf: {
|
|
|
4692
5113
|
*
|
|
4693
5114
|
* // With a Filter
|
|
4694
5115
|
* const recovered2 = program.pipe(
|
|
4695
|
-
* Effect.
|
|
5116
|
+
* Effect.catchFilter(
|
|
4696
5117
|
* Filter.tagged("NotFound"),
|
|
4697
5118
|
* (error) => Effect.succeed(`missing:${error.id}`)
|
|
4698
5119
|
* )
|
|
@@ -4702,7 +5123,29 @@ export declare const catchIf: {
|
|
|
4702
5123
|
* @since 2.0.0
|
|
4703
5124
|
* @category Error Handling
|
|
4704
5125
|
*/
|
|
4705
|
-
<A, E, R,
|
|
5126
|
+
<A, E, R, A2, E2, R2, A3 = never, E3 = E, R3 = never>(self: Effect<A, E, R>, predicate: Predicate.Predicate<E>, f: (e: E) => Effect<A2, E2, R2>, orElse?: ((e: E) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
5127
|
+
};
|
|
5128
|
+
/**
|
|
5129
|
+
* Recovers from specific errors using a `Filter`.
|
|
5130
|
+
*
|
|
5131
|
+
* @since 4.0.0
|
|
5132
|
+
* @category Error Handling
|
|
5133
|
+
*/
|
|
5134
|
+
export declare const catchFilter: {
|
|
5135
|
+
/**
|
|
5136
|
+
* Recovers from specific errors using a `Filter`.
|
|
5137
|
+
*
|
|
5138
|
+
* @since 4.0.0
|
|
5139
|
+
* @category Error Handling
|
|
5140
|
+
*/
|
|
5141
|
+
<E, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(filter: Filter.Filter<NoInfer<E>, EB, X>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined): <A, R>(self: Effect<A, E, R>) => Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
5142
|
+
/**
|
|
5143
|
+
* Recovers from specific errors using a `Filter`.
|
|
5144
|
+
*
|
|
5145
|
+
* @since 4.0.0
|
|
5146
|
+
* @category Error Handling
|
|
5147
|
+
*/
|
|
5148
|
+
<A, E, R, EB, A2, E2, R2, X, A3 = never, E3 = X, R3 = never>(self: Effect<A, E, R>, filter: Filter.Filter<NoInfer<E>, EB, X>, f: (e: EB) => Effect<A2, E2, R2>, orElse?: ((e: X) => Effect<A3, E3, R3>) | undefined): Effect<A | A2 | A3, E2 | E3, R | R2 | R3>;
|
|
4706
5149
|
};
|
|
4707
5150
|
/**
|
|
4708
5151
|
* Catches `NoSuchElementError` failures and converts them to `Option.none`.
|
|
@@ -4808,7 +5251,7 @@ export declare const catchCauseIf: {
|
|
|
4808
5251
|
* @since 4.0.0
|
|
4809
5252
|
* @category Error Handling
|
|
4810
5253
|
*/
|
|
4811
|
-
<E,
|
|
5254
|
+
<E, B, E2, R2>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A | B, E | E2, R | R2>;
|
|
4812
5255
|
/**
|
|
4813
5256
|
* Recovers from specific failures based on a predicate.
|
|
4814
5257
|
*
|
|
@@ -4847,7 +5290,29 @@ export declare const catchCauseIf: {
|
|
|
4847
5290
|
* @since 4.0.0
|
|
4848
5291
|
* @category Error Handling
|
|
4849
5292
|
*/
|
|
4850
|
-
<A, E, R, B, E2, R2
|
|
5293
|
+
<A, E, R, B, E2, R2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A | B, E | E2, R | R2>;
|
|
5294
|
+
};
|
|
5295
|
+
/**
|
|
5296
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5297
|
+
*
|
|
5298
|
+
* @since 4.0.0
|
|
5299
|
+
* @category Error Handling
|
|
5300
|
+
*/
|
|
5301
|
+
export declare const catchCauseFilter: {
|
|
5302
|
+
/**
|
|
5303
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5304
|
+
*
|
|
5305
|
+
* @since 4.0.0
|
|
5306
|
+
* @category Error Handling
|
|
5307
|
+
*/
|
|
5308
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>;
|
|
5309
|
+
/**
|
|
5310
|
+
* Recovers from specific failures based on a `Filter`.
|
|
5311
|
+
*
|
|
5312
|
+
* @since 4.0.0
|
|
5313
|
+
* @category Error Handling
|
|
5314
|
+
*/
|
|
5315
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(self: Effect<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A | B, Cause.Cause.Error<X> | E2, R | R2>;
|
|
4851
5316
|
};
|
|
4852
5317
|
/**
|
|
4853
5318
|
* The `mapError` function is used to transform or modify the error
|
|
@@ -4864,17 +5329,19 @@ export declare const catchCauseIf: {
|
|
|
4864
5329
|
*
|
|
4865
5330
|
* @example
|
|
4866
5331
|
* ```ts
|
|
4867
|
-
* import { Effect } from "effect"
|
|
5332
|
+
* import { Data, Effect } from "effect"
|
|
5333
|
+
*
|
|
5334
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
4868
5335
|
*
|
|
4869
5336
|
* // ┌─── Effect<number, string, never>
|
|
4870
5337
|
* // ▼
|
|
4871
5338
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
4872
5339
|
*
|
|
4873
|
-
* // ┌─── Effect<number,
|
|
5340
|
+
* // ┌─── Effect<number, TaskError, never>
|
|
4874
5341
|
* // ▼
|
|
4875
5342
|
* const mapped = Effect.mapError(
|
|
4876
5343
|
* simulatedTask,
|
|
4877
|
-
* (message) => new
|
|
5344
|
+
* (message) => new TaskError({ message })
|
|
4878
5345
|
* )
|
|
4879
5346
|
* ```
|
|
4880
5347
|
*
|
|
@@ -4897,17 +5364,19 @@ export declare const mapError: {
|
|
|
4897
5364
|
*
|
|
4898
5365
|
* @example
|
|
4899
5366
|
* ```ts
|
|
4900
|
-
* import { Effect } from "effect"
|
|
5367
|
+
* import { Data, Effect } from "effect"
|
|
5368
|
+
*
|
|
5369
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
4901
5370
|
*
|
|
4902
5371
|
* // ┌─── Effect<number, string, never>
|
|
4903
5372
|
* // ▼
|
|
4904
5373
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
4905
5374
|
*
|
|
4906
|
-
* // ┌─── Effect<number,
|
|
5375
|
+
* // ┌─── Effect<number, TaskError, never>
|
|
4907
5376
|
* // ▼
|
|
4908
5377
|
* const mapped = Effect.mapError(
|
|
4909
5378
|
* simulatedTask,
|
|
4910
|
-
* (message) => new
|
|
5379
|
+
* (message) => new TaskError({ message })
|
|
4911
5380
|
* )
|
|
4912
5381
|
* ```
|
|
4913
5382
|
*
|
|
@@ -4930,17 +5399,19 @@ export declare const mapError: {
|
|
|
4930
5399
|
*
|
|
4931
5400
|
* @example
|
|
4932
5401
|
* ```ts
|
|
4933
|
-
* import { Effect } from "effect"
|
|
5402
|
+
* import { Data, Effect } from "effect"
|
|
5403
|
+
*
|
|
5404
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
4934
5405
|
*
|
|
4935
5406
|
* // ┌─── Effect<number, string, never>
|
|
4936
5407
|
* // ▼
|
|
4937
5408
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
4938
5409
|
*
|
|
4939
|
-
* // ┌─── Effect<number,
|
|
5410
|
+
* // ┌─── Effect<number, TaskError, never>
|
|
4940
5411
|
* // ▼
|
|
4941
5412
|
* const mapped = Effect.mapError(
|
|
4942
5413
|
* simulatedTask,
|
|
4943
|
-
* (message) => new
|
|
5414
|
+
* (message) => new TaskError({ message })
|
|
4944
5415
|
* )
|
|
4945
5416
|
* ```
|
|
4946
5417
|
*
|
|
@@ -4961,16 +5432,18 @@ export declare const mapError: {
|
|
|
4961
5432
|
*
|
|
4962
5433
|
* @example
|
|
4963
5434
|
* ```ts
|
|
4964
|
-
* import { Effect } from "effect"
|
|
5435
|
+
* import { Data, Effect } from "effect"
|
|
5436
|
+
*
|
|
5437
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
4965
5438
|
*
|
|
4966
5439
|
* // ┌─── Effect<number, string, never>
|
|
4967
5440
|
* // ▼
|
|
4968
5441
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
4969
5442
|
*
|
|
4970
|
-
* // ┌─── Effect<boolean,
|
|
5443
|
+
* // ┌─── Effect<boolean, TaskError, never>
|
|
4971
5444
|
* // ▼
|
|
4972
5445
|
* const modified = Effect.mapBoth(simulatedTask, {
|
|
4973
|
-
* onFailure: (message) => new
|
|
5446
|
+
* onFailure: (message) => new TaskError({ message }),
|
|
4974
5447
|
* onSuccess: (n) => n > 0
|
|
4975
5448
|
* })
|
|
4976
5449
|
* ```
|
|
@@ -4994,16 +5467,18 @@ export declare const mapBoth: {
|
|
|
4994
5467
|
*
|
|
4995
5468
|
* @example
|
|
4996
5469
|
* ```ts
|
|
4997
|
-
* import { Effect } from "effect"
|
|
5470
|
+
* import { Data, Effect } from "effect"
|
|
5471
|
+
*
|
|
5472
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
4998
5473
|
*
|
|
4999
5474
|
* // ┌─── Effect<number, string, never>
|
|
5000
5475
|
* // ▼
|
|
5001
5476
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5002
5477
|
*
|
|
5003
|
-
* // ┌─── Effect<boolean,
|
|
5478
|
+
* // ┌─── Effect<boolean, TaskError, never>
|
|
5004
5479
|
* // ▼
|
|
5005
5480
|
* const modified = Effect.mapBoth(simulatedTask, {
|
|
5006
|
-
* onFailure: (message) => new
|
|
5481
|
+
* onFailure: (message) => new TaskError({ message }),
|
|
5007
5482
|
* onSuccess: (n) => n > 0
|
|
5008
5483
|
* })
|
|
5009
5484
|
* ```
|
|
@@ -5030,16 +5505,18 @@ export declare const mapBoth: {
|
|
|
5030
5505
|
*
|
|
5031
5506
|
* @example
|
|
5032
5507
|
* ```ts
|
|
5033
|
-
* import { Effect } from "effect"
|
|
5508
|
+
* import { Data, Effect } from "effect"
|
|
5509
|
+
*
|
|
5510
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5034
5511
|
*
|
|
5035
5512
|
* // ┌─── Effect<number, string, never>
|
|
5036
5513
|
* // ▼
|
|
5037
5514
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5038
5515
|
*
|
|
5039
|
-
* // ┌─── Effect<boolean,
|
|
5516
|
+
* // ┌─── Effect<boolean, TaskError, never>
|
|
5040
5517
|
* // ▼
|
|
5041
5518
|
* const modified = Effect.mapBoth(simulatedTask, {
|
|
5042
|
-
* onFailure: (message) => new
|
|
5519
|
+
* onFailure: (message) => new TaskError({ message }),
|
|
5043
5520
|
* onSuccess: (n) => n > 0
|
|
5044
5521
|
* })
|
|
5045
5522
|
* ```
|
|
@@ -5073,11 +5550,13 @@ export declare const mapBoth: {
|
|
|
5073
5550
|
* @example
|
|
5074
5551
|
* ```ts
|
|
5075
5552
|
* // Title: Propagating an Error as a Defect
|
|
5076
|
-
* import { Effect } from "effect"
|
|
5553
|
+
* import { Data, Effect } from "effect"
|
|
5554
|
+
*
|
|
5555
|
+
* class DivideByZeroError extends Data.TaggedError("DivideByZeroError")<{}> {}
|
|
5077
5556
|
*
|
|
5078
5557
|
* const divide = (a: number, b: number) =>
|
|
5079
5558
|
* b === 0
|
|
5080
|
-
* ? Effect.fail(new
|
|
5559
|
+
* ? Effect.fail(new DivideByZeroError())
|
|
5081
5560
|
* : Effect.succeed(a / b)
|
|
5082
5561
|
*
|
|
5083
5562
|
* // ┌─── Effect<number, never, never>
|
|
@@ -5086,7 +5565,7 @@ export declare const mapBoth: {
|
|
|
5086
5565
|
*
|
|
5087
5566
|
* Effect.runPromise(program).catch(console.error)
|
|
5088
5567
|
* // Output:
|
|
5089
|
-
* // (FiberFailure)
|
|
5568
|
+
* // (FiberFailure) DivideByZeroError
|
|
5090
5569
|
* // ...stack trace...
|
|
5091
5570
|
* ```
|
|
5092
5571
|
*
|
|
@@ -5454,7 +5933,7 @@ export declare const tapCauseIf: {
|
|
|
5454
5933
|
* @since 4.0.0
|
|
5455
5934
|
* @category Sequencing
|
|
5456
5935
|
*/
|
|
5457
|
-
<E,
|
|
5936
|
+
<E, B, E2, R2>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>;
|
|
5458
5937
|
/**
|
|
5459
5938
|
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5460
5939
|
*
|
|
@@ -5483,7 +5962,29 @@ export declare const tapCauseIf: {
|
|
|
5483
5962
|
* @since 4.0.0
|
|
5484
5963
|
* @category Sequencing
|
|
5485
5964
|
*/
|
|
5486
|
-
<A, E, R,
|
|
5965
|
+
<A, E, R, B, E2, R2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A, E | E2, R | R2>;
|
|
5966
|
+
};
|
|
5967
|
+
/**
|
|
5968
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5969
|
+
*
|
|
5970
|
+
* @since 4.0.0
|
|
5971
|
+
* @category Sequencing
|
|
5972
|
+
*/
|
|
5973
|
+
export declare const tapCauseFilter: {
|
|
5974
|
+
/**
|
|
5975
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5976
|
+
*
|
|
5977
|
+
* @since 4.0.0
|
|
5978
|
+
* @category Sequencing
|
|
5979
|
+
*/
|
|
5980
|
+
<E, B, E2, R2, EB, X extends Cause.Cause<any>>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | E2, R | R2>;
|
|
5981
|
+
/**
|
|
5982
|
+
* Conditionally executes a side effect based on the cause of a failed effect.
|
|
5983
|
+
*
|
|
5984
|
+
* @since 4.0.0
|
|
5985
|
+
* @category Sequencing
|
|
5986
|
+
*/
|
|
5987
|
+
<A, E, R, B, E2, R2, EB, X extends Cause.Cause<any>>(self: Effect<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (a: EB, cause: Cause.Cause<E>) => Effect<B, E2, R2>): Effect<A, E | E2, R | R2>;
|
|
5487
5988
|
};
|
|
5488
5989
|
/**
|
|
5489
5990
|
* Inspect severe errors or defects (non-recoverable failures) in an effect.
|
|
@@ -5660,7 +6161,7 @@ export declare const tapDefect: {
|
|
|
5660
6161
|
* attempts++
|
|
5661
6162
|
* yield* Console.log(`Attempt ${attempts}`)
|
|
5662
6163
|
* if (attempts < 3) {
|
|
5663
|
-
* yield* Effect.fail("Not ready")
|
|
6164
|
+
* return yield* Effect.fail("Not ready")
|
|
5664
6165
|
* }
|
|
5665
6166
|
* return "Ready"
|
|
5666
6167
|
* })
|
|
@@ -5769,13 +6270,15 @@ export declare namespace Retry {
|
|
|
5769
6270
|
*
|
|
5770
6271
|
* @example
|
|
5771
6272
|
* ```ts
|
|
5772
|
-
* import { Effect, Schedule } from "effect"
|
|
6273
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6274
|
+
*
|
|
6275
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
5773
6276
|
*
|
|
5774
6277
|
* let attempt = 0
|
|
5775
|
-
* const task = Effect.callback<string,
|
|
6278
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
5776
6279
|
* attempt++
|
|
5777
6280
|
* if (attempt <= 2) {
|
|
5778
|
-
* resume(Effect.fail(new
|
|
6281
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
5779
6282
|
* } else {
|
|
5780
6283
|
* resume(Effect.succeed("Success!"))
|
|
5781
6284
|
* }
|
|
@@ -5818,13 +6321,15 @@ export declare const retry: {
|
|
|
5818
6321
|
*
|
|
5819
6322
|
* @example
|
|
5820
6323
|
* ```ts
|
|
5821
|
-
* import { Effect, Schedule } from "effect"
|
|
6324
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6325
|
+
*
|
|
6326
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
5822
6327
|
*
|
|
5823
6328
|
* let attempt = 0
|
|
5824
|
-
* const task = Effect.callback<string,
|
|
6329
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
5825
6330
|
* attempt++
|
|
5826
6331
|
* if (attempt <= 2) {
|
|
5827
|
-
* resume(Effect.fail(new
|
|
6332
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
5828
6333
|
* } else {
|
|
5829
6334
|
* resume(Effect.succeed("Success!"))
|
|
5830
6335
|
* }
|
|
@@ -5867,13 +6372,15 @@ export declare const retry: {
|
|
|
5867
6372
|
*
|
|
5868
6373
|
* @example
|
|
5869
6374
|
* ```ts
|
|
5870
|
-
* import { Effect, Schedule } from "effect"
|
|
6375
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6376
|
+
*
|
|
6377
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
5871
6378
|
*
|
|
5872
6379
|
* let attempt = 0
|
|
5873
|
-
* const task = Effect.callback<string,
|
|
6380
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
5874
6381
|
* attempt++
|
|
5875
6382
|
* if (attempt <= 2) {
|
|
5876
|
-
* resume(Effect.fail(new
|
|
6383
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
5877
6384
|
* } else {
|
|
5878
6385
|
* resume(Effect.succeed("Success!"))
|
|
5879
6386
|
* }
|
|
@@ -5916,13 +6423,15 @@ export declare const retry: {
|
|
|
5916
6423
|
*
|
|
5917
6424
|
* @example
|
|
5918
6425
|
* ```ts
|
|
5919
|
-
* import { Effect, Schedule } from "effect"
|
|
6426
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6427
|
+
*
|
|
6428
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
5920
6429
|
*
|
|
5921
6430
|
* let attempt = 0
|
|
5922
|
-
* const task = Effect.callback<string,
|
|
6431
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
5923
6432
|
* attempt++
|
|
5924
6433
|
* if (attempt <= 2) {
|
|
5925
|
-
* resume(Effect.fail(new
|
|
6434
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
5926
6435
|
* } else {
|
|
5927
6436
|
* resume(Effect.succeed("Success!"))
|
|
5928
6437
|
* }
|
|
@@ -5965,13 +6474,15 @@ export declare const retry: {
|
|
|
5965
6474
|
*
|
|
5966
6475
|
* @example
|
|
5967
6476
|
* ```ts
|
|
5968
|
-
* import { Effect, Schedule } from "effect"
|
|
6477
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6478
|
+
*
|
|
6479
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
5969
6480
|
*
|
|
5970
6481
|
* let attempt = 0
|
|
5971
|
-
* const task = Effect.callback<string,
|
|
6482
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
5972
6483
|
* attempt++
|
|
5973
6484
|
* if (attempt <= 2) {
|
|
5974
|
-
* resume(Effect.fail(new
|
|
6485
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
5975
6486
|
* } else {
|
|
5976
6487
|
* resume(Effect.succeed("Success!"))
|
|
5977
6488
|
* }
|
|
@@ -6014,13 +6525,15 @@ export declare const retry: {
|
|
|
6014
6525
|
*
|
|
6015
6526
|
* @example
|
|
6016
6527
|
* ```ts
|
|
6017
|
-
* import { Effect, Schedule } from "effect"
|
|
6528
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6529
|
+
*
|
|
6530
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6018
6531
|
*
|
|
6019
6532
|
* let attempt = 0
|
|
6020
|
-
* const task = Effect.callback<string,
|
|
6533
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6021
6534
|
* attempt++
|
|
6022
6535
|
* if (attempt <= 2) {
|
|
6023
|
-
* resume(Effect.fail(new
|
|
6536
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6024
6537
|
* } else {
|
|
6025
6538
|
* resume(Effect.succeed("Success!"))
|
|
6026
6539
|
* }
|
|
@@ -6063,13 +6576,15 @@ export declare const retry: {
|
|
|
6063
6576
|
*
|
|
6064
6577
|
* @example
|
|
6065
6578
|
* ```ts
|
|
6066
|
-
* import { Effect, Schedule } from "effect"
|
|
6579
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6580
|
+
*
|
|
6581
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6067
6582
|
*
|
|
6068
6583
|
* let attempt = 0
|
|
6069
|
-
* const task = Effect.callback<string,
|
|
6584
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6070
6585
|
* attempt++
|
|
6071
6586
|
* if (attempt <= 2) {
|
|
6072
|
-
* resume(Effect.fail(new
|
|
6587
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6073
6588
|
* } else {
|
|
6074
6589
|
* resume(Effect.succeed("Success!"))
|
|
6075
6590
|
* }
|
|
@@ -6110,14 +6625,16 @@ export declare const retry: {
|
|
|
6110
6625
|
*
|
|
6111
6626
|
* @example
|
|
6112
6627
|
* ```ts
|
|
6113
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
6628
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
6629
|
+
*
|
|
6630
|
+
* class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
|
|
6114
6631
|
*
|
|
6115
6632
|
* let attempt = 0
|
|
6116
6633
|
* const networkRequest = Effect.gen(function*() {
|
|
6117
6634
|
* attempt++
|
|
6118
6635
|
* yield* Console.log(`Network attempt ${attempt}`)
|
|
6119
6636
|
* if (attempt < 3) {
|
|
6120
|
-
* return yield* Effect.fail(new
|
|
6637
|
+
* return yield* Effect.fail(new NetworkTimeoutError())
|
|
6121
6638
|
* }
|
|
6122
6639
|
* return "Network data"
|
|
6123
6640
|
* })
|
|
@@ -6165,14 +6682,16 @@ export declare const retryOrElse: {
|
|
|
6165
6682
|
*
|
|
6166
6683
|
* @example
|
|
6167
6684
|
* ```ts
|
|
6168
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
6685
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
6686
|
+
*
|
|
6687
|
+
* class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
|
|
6169
6688
|
*
|
|
6170
6689
|
* let attempt = 0
|
|
6171
6690
|
* const networkRequest = Effect.gen(function*() {
|
|
6172
6691
|
* attempt++
|
|
6173
6692
|
* yield* Console.log(`Network attempt ${attempt}`)
|
|
6174
6693
|
* if (attempt < 3) {
|
|
6175
|
-
* return yield* Effect.fail(new
|
|
6694
|
+
* return yield* Effect.fail(new NetworkTimeoutError())
|
|
6176
6695
|
* }
|
|
6177
6696
|
* return "Network data"
|
|
6178
6697
|
* })
|
|
@@ -6220,14 +6739,16 @@ export declare const retryOrElse: {
|
|
|
6220
6739
|
*
|
|
6221
6740
|
* @example
|
|
6222
6741
|
* ```ts
|
|
6223
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
6742
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
6743
|
+
*
|
|
6744
|
+
* class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
|
|
6224
6745
|
*
|
|
6225
6746
|
* let attempt = 0
|
|
6226
6747
|
* const networkRequest = Effect.gen(function*() {
|
|
6227
6748
|
* attempt++
|
|
6228
6749
|
* yield* Console.log(`Network attempt ${attempt}`)
|
|
6229
6750
|
* if (attempt < 3) {
|
|
6230
|
-
* return yield* Effect.fail(new
|
|
6751
|
+
* return yield* Effect.fail(new NetworkTimeoutError())
|
|
6231
6752
|
* }
|
|
6232
6753
|
* return "Network data"
|
|
6233
6754
|
* })
|
|
@@ -6300,7 +6821,8 @@ export declare const sandbox: <A, E, R>(self: Effect<A, E, R>) => Effect<A, Caus
|
|
|
6300
6821
|
* it succeeds or fails. This is useful when you only care about the side
|
|
6301
6822
|
* effects of the effect and do not need to handle or process its outcome.
|
|
6302
6823
|
*
|
|
6303
|
-
* Use the `log` option to emit the full {@link Cause} when the effect fails
|
|
6824
|
+
* Use the `log` option to emit the full {@link Cause} when the effect fails,
|
|
6825
|
+
* and `message` to prepend a custom log message.
|
|
6304
6826
|
*
|
|
6305
6827
|
* @example
|
|
6306
6828
|
* ```ts
|
|
@@ -6324,7 +6846,7 @@ export declare const sandbox: <A, E, R>(self: Effect<A, E, R>) => Effect<A, Caus
|
|
|
6324
6846
|
* const task = Effect.fail("Uh oh!")
|
|
6325
6847
|
*
|
|
6326
6848
|
* const program = task.pipe(Effect.ignore({ log: true }))
|
|
6327
|
-
* const programWarn = task.pipe(Effect.ignore({ log: "Warn" }))
|
|
6849
|
+
* const programWarn = task.pipe(Effect.ignore({ log: "Warn", message: "Ignoring task failure" }))
|
|
6328
6850
|
* ```
|
|
6329
6851
|
*
|
|
6330
6852
|
* **Previously Known As**
|
|
@@ -6337,16 +6859,20 @@ export declare const sandbox: <A, E, R>(self: Effect<A, E, R>) => Effect<A, Caus
|
|
|
6337
6859
|
* @category Error Handling
|
|
6338
6860
|
*/
|
|
6339
6861
|
export declare const ignore: <Arg extends Effect<any, any, any> | {
|
|
6340
|
-
readonly log?: boolean |
|
|
6862
|
+
readonly log?: boolean | Severity | undefined;
|
|
6863
|
+
readonly message?: string | undefined;
|
|
6341
6864
|
} | undefined = {
|
|
6342
|
-
readonly log?: boolean |
|
|
6865
|
+
readonly log?: boolean | Severity | undefined;
|
|
6866
|
+
readonly message?: string | undefined;
|
|
6343
6867
|
}>(effectOrOptions?: Arg, options?: {
|
|
6344
|
-
readonly log?: boolean |
|
|
6868
|
+
readonly log?: boolean | Severity | undefined;
|
|
6869
|
+
readonly message?: string | undefined;
|
|
6345
6870
|
} | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<void, never, _R> : <A, E, R>(self: Effect<A, E, R>) => Effect<void, never, R>;
|
|
6346
6871
|
/**
|
|
6347
6872
|
* Ignores the effect's failure cause, including defects and interruptions.
|
|
6348
6873
|
*
|
|
6349
|
-
* Use the `log` option to emit the full {@link Cause} when the effect fails
|
|
6874
|
+
* Use the `log` option to emit the full {@link Cause} when the effect fails,
|
|
6875
|
+
* and `message` to prepend a custom log message.
|
|
6350
6876
|
*
|
|
6351
6877
|
* @example
|
|
6352
6878
|
* ```ts
|
|
@@ -6355,18 +6881,21 @@ export declare const ignore: <Arg extends Effect<any, any, any> | {
|
|
|
6355
6881
|
* const task = Effect.fail("boom")
|
|
6356
6882
|
*
|
|
6357
6883
|
* const program = task.pipe(Effect.ignoreCause)
|
|
6358
|
-
* const programLog = task.pipe(Effect.ignoreCause({ log: true }))
|
|
6884
|
+
* const programLog = task.pipe(Effect.ignoreCause({ log: true, message: "Ignoring failure cause" }))
|
|
6359
6885
|
* ```
|
|
6360
6886
|
*
|
|
6361
6887
|
* @since 4.0.0
|
|
6362
6888
|
* @category Error Handling
|
|
6363
6889
|
*/
|
|
6364
6890
|
export declare const ignoreCause: <Arg extends Effect<any, any, any> | {
|
|
6365
|
-
readonly log?: boolean |
|
|
6891
|
+
readonly log?: boolean | Severity | undefined;
|
|
6892
|
+
readonly message?: string | undefined;
|
|
6366
6893
|
} | undefined = {
|
|
6367
|
-
readonly log?: boolean |
|
|
6894
|
+
readonly log?: boolean | Severity | undefined;
|
|
6895
|
+
readonly message?: string | undefined;
|
|
6368
6896
|
}>(effectOrOptions?: Arg, options?: {
|
|
6369
|
-
readonly log?: boolean |
|
|
6897
|
+
readonly log?: boolean | Severity | undefined;
|
|
6898
|
+
readonly message?: string | undefined;
|
|
6370
6899
|
} | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<void, never, _R> : <A, E, R>(self: Effect<A, E, R>) => Effect<void, never, R>;
|
|
6371
6900
|
/**
|
|
6372
6901
|
* Apply an `ExecutionPlan` to an effect, retrying with step-provided resources
|
|
@@ -6384,7 +6913,10 @@ export declare const ignoreCause: <Arg extends Effect<any, any, any> | {
|
|
|
6384
6913
|
*
|
|
6385
6914
|
* const fetchUrl = Effect.gen(function*() {
|
|
6386
6915
|
* const endpoint = yield* Effect.service(Endpoint)
|
|
6387
|
-
*
|
|
6916
|
+
* if (endpoint.url === "bad") {
|
|
6917
|
+
* return yield* Effect.fail("Unavailable")
|
|
6918
|
+
* }
|
|
6919
|
+
* return endpoint.url
|
|
6388
6920
|
* })
|
|
6389
6921
|
*
|
|
6390
6922
|
* const plan = ExecutionPlan.make(
|
|
@@ -6415,7 +6947,10 @@ export declare const withExecutionPlan: {
|
|
|
6415
6947
|
*
|
|
6416
6948
|
* const fetchUrl = Effect.gen(function*() {
|
|
6417
6949
|
* const endpoint = yield* Effect.service(Endpoint)
|
|
6418
|
-
*
|
|
6950
|
+
* if (endpoint.url === "bad") {
|
|
6951
|
+
* return yield* Effect.fail("Unavailable")
|
|
6952
|
+
* }
|
|
6953
|
+
* return endpoint.url
|
|
6419
6954
|
* })
|
|
6420
6955
|
*
|
|
6421
6956
|
* const plan = ExecutionPlan.make(
|
|
@@ -6451,7 +6986,10 @@ export declare const withExecutionPlan: {
|
|
|
6451
6986
|
*
|
|
6452
6987
|
* const fetchUrl = Effect.gen(function*() {
|
|
6453
6988
|
* const endpoint = yield* Effect.service(Endpoint)
|
|
6454
|
-
*
|
|
6989
|
+
* if (endpoint.url === "bad") {
|
|
6990
|
+
* return yield* Effect.fail("Unavailable")
|
|
6991
|
+
* }
|
|
6992
|
+
* return endpoint.url
|
|
6455
6993
|
* })
|
|
6456
6994
|
*
|
|
6457
6995
|
* const plan = ExecutionPlan.make(
|
|
@@ -6472,6 +7010,22 @@ export declare const withExecutionPlan: {
|
|
|
6472
7010
|
requirements: PlanR;
|
|
6473
7011
|
}>): Effect<A, E | PlanE, Exclude<R, Provides> | PlanR>;
|
|
6474
7012
|
};
|
|
7013
|
+
/**
|
|
7014
|
+
* Runs an effect and reports any errors to the configured `ErrorReporter`s.
|
|
7015
|
+
*
|
|
7016
|
+
* If the `defectsOnly` option is set to `true`, only defects (unrecoverable
|
|
7017
|
+
* errors) will be reported, while regular failures will be ignored.
|
|
7018
|
+
*
|
|
7019
|
+
* @since 4.0.0
|
|
7020
|
+
* @category Error Handling
|
|
7021
|
+
*/
|
|
7022
|
+
export declare const withErrorReporting: <Arg extends Effect<any, any, any> | {
|
|
7023
|
+
readonly defectsOnly?: boolean | undefined;
|
|
7024
|
+
} | undefined = {
|
|
7025
|
+
readonly defectsOnly?: boolean | undefined;
|
|
7026
|
+
}>(effectOrOptions: Arg, options?: {
|
|
7027
|
+
readonly defectsOnly?: boolean | undefined;
|
|
7028
|
+
} | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Arg : <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
|
|
6475
7029
|
/**
|
|
6476
7030
|
* Replaces the original failure with a success value, ensuring the effect
|
|
6477
7031
|
* cannot fail.
|
|
@@ -6692,7 +7246,7 @@ export declare const timeout: {
|
|
|
6692
7246
|
* @since 2.0.0
|
|
6693
7247
|
* @category Delays & Timeouts
|
|
6694
7248
|
*/
|
|
6695
|
-
(duration: Duration.
|
|
7249
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | Cause.TimeoutError, R>;
|
|
6696
7250
|
/**
|
|
6697
7251
|
* Adds a time limit to an effect, triggering a timeout if the effect exceeds
|
|
6698
7252
|
* the duration.
|
|
@@ -6739,7 +7293,7 @@ export declare const timeout: {
|
|
|
6739
7293
|
* @since 2.0.0
|
|
6740
7294
|
* @category Delays & Timeouts
|
|
6741
7295
|
*/
|
|
6742
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7296
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E | Cause.TimeoutError, R>;
|
|
6743
7297
|
};
|
|
6744
7298
|
/**
|
|
6745
7299
|
* Handles timeouts by returning an `Option` that represents either the result
|
|
@@ -6840,7 +7394,7 @@ export declare const timeoutOption: {
|
|
|
6840
7394
|
* @since 3.1.0
|
|
6841
7395
|
* @category Delays & Timeouts
|
|
6842
7396
|
*/
|
|
6843
|
-
(duration: Duration.
|
|
7397
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>;
|
|
6844
7398
|
/**
|
|
6845
7399
|
* Handles timeouts by returning an `Option` that represents either the result
|
|
6846
7400
|
* or a timeout.
|
|
@@ -6890,7 +7444,7 @@ export declare const timeoutOption: {
|
|
|
6890
7444
|
* @since 3.1.0
|
|
6891
7445
|
* @category Delays & Timeouts
|
|
6892
7446
|
*/
|
|
6893
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7447
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<Option<A>, E, R>;
|
|
6894
7448
|
};
|
|
6895
7449
|
/**
|
|
6896
7450
|
* Applies a timeout to an effect, with a fallback effect executed if the timeout is reached.
|
|
@@ -6966,7 +7520,7 @@ export declare const timeoutOrElse: {
|
|
|
6966
7520
|
* @category Delays & Timeouts
|
|
6967
7521
|
*/
|
|
6968
7522
|
<A2, E2, R2>(options: {
|
|
6969
|
-
readonly duration: Duration.
|
|
7523
|
+
readonly duration: Duration.Input;
|
|
6970
7524
|
readonly onTimeout: LazyArg<Effect<A2, E2, R2>>;
|
|
6971
7525
|
}): <A, E, R>(self: Effect<A, E, R>) => Effect<A | A2, E | E2, R | R2>;
|
|
6972
7526
|
/**
|
|
@@ -7006,7 +7560,7 @@ export declare const timeoutOrElse: {
|
|
|
7006
7560
|
* @category Delays & Timeouts
|
|
7007
7561
|
*/
|
|
7008
7562
|
<A, E, R, A2, E2, R2>(self: Effect<A, E, R>, options: {
|
|
7009
|
-
readonly duration: Duration.
|
|
7563
|
+
readonly duration: Duration.Input;
|
|
7010
7564
|
readonly onTimeout: LazyArg<Effect<A2, E2, R2>>;
|
|
7011
7565
|
}): Effect<A | A2, E | E2, R | R2>;
|
|
7012
7566
|
};
|
|
@@ -7051,7 +7605,7 @@ export declare const delay: {
|
|
|
7051
7605
|
* @since 2.0.0
|
|
7052
7606
|
* @category Delays & Timeouts
|
|
7053
7607
|
*/
|
|
7054
|
-
(duration: Duration.
|
|
7608
|
+
(duration: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
|
|
7055
7609
|
/**
|
|
7056
7610
|
* Returns an effect that is delayed from this effect by the specified
|
|
7057
7611
|
* `Duration`.
|
|
@@ -7072,7 +7626,7 @@ export declare const delay: {
|
|
|
7072
7626
|
* @since 2.0.0
|
|
7073
7627
|
* @category Delays & Timeouts
|
|
7074
7628
|
*/
|
|
7075
|
-
<A, E, R>(self: Effect<A, E, R>, duration: Duration.
|
|
7629
|
+
<A, E, R>(self: Effect<A, E, R>, duration: Duration.Input): Effect<A, E, R>;
|
|
7076
7630
|
};
|
|
7077
7631
|
/**
|
|
7078
7632
|
* Returns an effect that suspends for the specified duration. This method is
|
|
@@ -7096,7 +7650,7 @@ export declare const delay: {
|
|
|
7096
7650
|
* @since 2.0.0
|
|
7097
7651
|
* @category Delays & Timeouts
|
|
7098
7652
|
*/
|
|
7099
|
-
export declare const sleep: (duration: Duration.
|
|
7653
|
+
export declare const sleep: (duration: Duration.Input) => Effect<void>;
|
|
7100
7654
|
/**
|
|
7101
7655
|
* Measures the runtime of an effect and returns the duration with its result.
|
|
7102
7656
|
*
|
|
@@ -7389,12 +7943,12 @@ export declare const raceFirst: {
|
|
|
7389
7943
|
}): Effect<A | A2, E | E2, R | R2>;
|
|
7390
7944
|
};
|
|
7391
7945
|
/**
|
|
7392
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7393
|
-
* predicate
|
|
7946
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7947
|
+
* predicate.
|
|
7394
7948
|
*
|
|
7395
7949
|
* @example
|
|
7396
7950
|
* ```ts
|
|
7397
|
-
* import { Effect
|
|
7951
|
+
* import { Effect } from "effect"
|
|
7398
7952
|
*
|
|
7399
7953
|
* // Sync predicate
|
|
7400
7954
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7402,10 +7956,7 @@ export declare const raceFirst: {
|
|
|
7402
7956
|
* // Effectful predicate
|
|
7403
7957
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7404
7958
|
*
|
|
7405
|
-
* //
|
|
7406
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7407
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7408
|
-
* )
|
|
7959
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7409
7960
|
* ```
|
|
7410
7961
|
*
|
|
7411
7962
|
* @since 2.0.0
|
|
@@ -7413,12 +7964,12 @@ export declare const raceFirst: {
|
|
|
7413
7964
|
*/
|
|
7414
7965
|
export declare const filter: {
|
|
7415
7966
|
/**
|
|
7416
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7417
|
-
* predicate
|
|
7967
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7968
|
+
* predicate.
|
|
7418
7969
|
*
|
|
7419
7970
|
* @example
|
|
7420
7971
|
* ```ts
|
|
7421
|
-
* import { Effect
|
|
7972
|
+
* import { Effect } from "effect"
|
|
7422
7973
|
*
|
|
7423
7974
|
* // Sync predicate
|
|
7424
7975
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7426,10 +7977,7 @@ export declare const filter: {
|
|
|
7426
7977
|
* // Effectful predicate
|
|
7427
7978
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7428
7979
|
*
|
|
7429
|
-
* //
|
|
7430
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7431
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7432
|
-
* )
|
|
7980
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7433
7981
|
* ```
|
|
7434
7982
|
*
|
|
7435
7983
|
* @since 2.0.0
|
|
@@ -7437,12 +7985,12 @@ export declare const filter: {
|
|
|
7437
7985
|
*/
|
|
7438
7986
|
<A, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>): (elements: Iterable<A>) => Effect<Array<B>>;
|
|
7439
7987
|
/**
|
|
7440
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7441
|
-
* predicate
|
|
7988
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
7989
|
+
* predicate.
|
|
7442
7990
|
*
|
|
7443
7991
|
* @example
|
|
7444
7992
|
* ```ts
|
|
7445
|
-
* import { Effect
|
|
7993
|
+
* import { Effect } from "effect"
|
|
7446
7994
|
*
|
|
7447
7995
|
* // Sync predicate
|
|
7448
7996
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7450,10 +7998,7 @@ export declare const filter: {
|
|
|
7450
7998
|
* // Effectful predicate
|
|
7451
7999
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7452
8000
|
*
|
|
7453
|
-
* //
|
|
7454
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7455
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7456
|
-
* )
|
|
8001
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7457
8002
|
* ```
|
|
7458
8003
|
*
|
|
7459
8004
|
* @since 2.0.0
|
|
@@ -7461,38 +8006,12 @@ export declare const filter: {
|
|
|
7461
8006
|
*/
|
|
7462
8007
|
<A>(predicate: Predicate.Predicate<NoInfer<A>>): (elements: Iterable<A>) => Effect<Array<A>>;
|
|
7463
8008
|
/**
|
|
7464
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7465
|
-
* predicate
|
|
8009
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8010
|
+
* predicate.
|
|
7466
8011
|
*
|
|
7467
8012
|
* @example
|
|
7468
8013
|
* ```ts
|
|
7469
|
-
* import { Effect
|
|
7470
|
-
*
|
|
7471
|
-
* // Sync predicate
|
|
7472
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
7473
|
-
*
|
|
7474
|
-
* // Effectful predicate
|
|
7475
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7476
|
-
*
|
|
7477
|
-
* // FilterEffect
|
|
7478
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7479
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7480
|
-
* )
|
|
7481
|
-
* ```
|
|
7482
|
-
*
|
|
7483
|
-
* @since 2.0.0
|
|
7484
|
-
* @category Filtering
|
|
7485
|
-
*/
|
|
7486
|
-
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>, options?: {
|
|
7487
|
-
readonly concurrency?: Concurrency | undefined;
|
|
7488
|
-
}): (elements: Iterable<A>) => Effect<Array<B>>;
|
|
7489
|
-
/**
|
|
7490
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7491
|
-
* predicate, or `Filter.FilterEffect`.
|
|
7492
|
-
*
|
|
7493
|
-
* @example
|
|
7494
|
-
* ```ts
|
|
7495
|
-
* import { Effect, Filter, Result } from "effect"
|
|
8014
|
+
* import { Effect } from "effect"
|
|
7496
8015
|
*
|
|
7497
8016
|
* // Sync predicate
|
|
7498
8017
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7500,36 +8019,7 @@ export declare const filter: {
|
|
|
7500
8019
|
* // Effectful predicate
|
|
7501
8020
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7502
8021
|
*
|
|
7503
|
-
* //
|
|
7504
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7505
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7506
|
-
* )
|
|
7507
|
-
* ```
|
|
7508
|
-
*
|
|
7509
|
-
* @since 2.0.0
|
|
7510
|
-
* @category Filtering
|
|
7511
|
-
*/
|
|
7512
|
-
<A, B, X, E, R>(filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
|
|
7513
|
-
readonly concurrency?: Concurrency | undefined;
|
|
7514
|
-
}): (elements: Iterable<A>) => Effect<Array<B>, E, R>;
|
|
7515
|
-
/**
|
|
7516
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7517
|
-
* predicate, or `Filter.FilterEffect`.
|
|
7518
|
-
*
|
|
7519
|
-
* @example
|
|
7520
|
-
* ```ts
|
|
7521
|
-
* import { Effect, Filter, Result } from "effect"
|
|
7522
|
-
*
|
|
7523
|
-
* // Sync predicate
|
|
7524
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
7525
|
-
*
|
|
7526
|
-
* // Effectful predicate
|
|
7527
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7528
|
-
*
|
|
7529
|
-
* // FilterEffect
|
|
7530
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7531
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7532
|
-
* )
|
|
8022
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7533
8023
|
* ```
|
|
7534
8024
|
*
|
|
7535
8025
|
* @since 2.0.0
|
|
@@ -7539,12 +8029,12 @@ export declare const filter: {
|
|
|
7539
8029
|
readonly concurrency?: Concurrency | undefined;
|
|
7540
8030
|
}): (iterable: Iterable<A>) => Effect<Array<A>, E, R>;
|
|
7541
8031
|
/**
|
|
7542
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7543
|
-
* predicate
|
|
8032
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8033
|
+
* predicate.
|
|
7544
8034
|
*
|
|
7545
8035
|
* @example
|
|
7546
8036
|
* ```ts
|
|
7547
|
-
* import { Effect
|
|
8037
|
+
* import { Effect } from "effect"
|
|
7548
8038
|
*
|
|
7549
8039
|
* // Sync predicate
|
|
7550
8040
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7552,10 +8042,7 @@ export declare const filter: {
|
|
|
7552
8042
|
* // Effectful predicate
|
|
7553
8043
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7554
8044
|
*
|
|
7555
|
-
* //
|
|
7556
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7557
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7558
|
-
* )
|
|
8045
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7559
8046
|
* ```
|
|
7560
8047
|
*
|
|
7561
8048
|
* @since 2.0.0
|
|
@@ -7563,12 +8050,12 @@ export declare const filter: {
|
|
|
7563
8050
|
*/
|
|
7564
8051
|
<A, B extends A>(elements: Iterable<A>, refinement: Predicate.Refinement<A, B>): Effect<Array<B>>;
|
|
7565
8052
|
/**
|
|
7566
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7567
|
-
* predicate
|
|
8053
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8054
|
+
* predicate.
|
|
7568
8055
|
*
|
|
7569
8056
|
* @example
|
|
7570
8057
|
* ```ts
|
|
7571
|
-
* import { Effect
|
|
8058
|
+
* import { Effect } from "effect"
|
|
7572
8059
|
*
|
|
7573
8060
|
* // Sync predicate
|
|
7574
8061
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7576,10 +8063,7 @@ export declare const filter: {
|
|
|
7576
8063
|
* // Effectful predicate
|
|
7577
8064
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7578
8065
|
*
|
|
7579
|
-
* //
|
|
7580
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7581
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7582
|
-
* )
|
|
8066
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7583
8067
|
* ```
|
|
7584
8068
|
*
|
|
7585
8069
|
* @since 2.0.0
|
|
@@ -7587,12 +8071,12 @@ export declare const filter: {
|
|
|
7587
8071
|
*/
|
|
7588
8072
|
<A>(elements: Iterable<A>, predicate: Predicate.Predicate<A>): Effect<Array<A>>;
|
|
7589
8073
|
/**
|
|
7590
|
-
* Filters elements of an iterable using a predicate, refinement, effectful
|
|
7591
|
-
* predicate
|
|
8074
|
+
* Filters elements of an iterable using a predicate, refinement, or effectful
|
|
8075
|
+
* predicate.
|
|
7592
8076
|
*
|
|
7593
8077
|
* @example
|
|
7594
8078
|
* ```ts
|
|
7595
|
-
* import { Effect
|
|
8079
|
+
* import { Effect } from "effect"
|
|
7596
8080
|
*
|
|
7597
8081
|
* // Sync predicate
|
|
7598
8082
|
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
@@ -7600,68 +8084,63 @@ export declare const filter: {
|
|
|
7600
8084
|
* // Effectful predicate
|
|
7601
8085
|
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7602
8086
|
*
|
|
7603
|
-
* //
|
|
7604
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7605
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7606
|
-
* )
|
|
8087
|
+
* // Use Effect.filterMapEffect for effectful Filter.Filter callbacks
|
|
7607
8088
|
* ```
|
|
7608
8089
|
*
|
|
7609
8090
|
* @since 2.0.0
|
|
7610
8091
|
* @category Filtering
|
|
7611
8092
|
*/
|
|
7612
|
-
<A,
|
|
8093
|
+
<A, E, R>(iterable: Iterable<A>, predicate: (a: NoInfer<A>, i: number) => Effect<boolean, E, R>, options?: {
|
|
8094
|
+
readonly concurrency?: Concurrency | undefined;
|
|
8095
|
+
}): Effect<Array<A>, E, R>;
|
|
8096
|
+
};
|
|
8097
|
+
/**
|
|
8098
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
8099
|
+
*
|
|
8100
|
+
* @since 4.0.0
|
|
8101
|
+
* @category Filtering
|
|
8102
|
+
*/
|
|
8103
|
+
export declare const filterMap: {
|
|
7613
8104
|
/**
|
|
7614
|
-
* Filters elements of an iterable
|
|
7615
|
-
* predicate, or `Filter.FilterEffect`.
|
|
7616
|
-
*
|
|
7617
|
-
* @example
|
|
7618
|
-
* ```ts
|
|
7619
|
-
* import { Effect, Filter, Result } from "effect"
|
|
7620
|
-
*
|
|
7621
|
-
* // Sync predicate
|
|
7622
|
-
* const evens = Effect.filter([1, 2, 3, 4], (n) => n % 2 === 0)
|
|
7623
|
-
*
|
|
7624
|
-
* // Effectful predicate
|
|
7625
|
-
* const checked = Effect.filter([1, 2, 3], (n) => Effect.succeed(n > 1))
|
|
7626
|
-
*
|
|
7627
|
-
* // FilterEffect
|
|
7628
|
-
* const mapped = Effect.filter([1, 2, 3, 4], (n) =>
|
|
7629
|
-
* Effect.succeed(n % 2 === 0 ? Result.succeed(n * 2) : Result.fail(n))
|
|
7630
|
-
* )
|
|
7631
|
-
* ```
|
|
8105
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
7632
8106
|
*
|
|
7633
|
-
* @since
|
|
8107
|
+
* @since 4.0.0
|
|
7634
8108
|
* @category Filtering
|
|
7635
8109
|
*/
|
|
7636
|
-
<A, B, X
|
|
7637
|
-
readonly concurrency?: Concurrency | undefined;
|
|
7638
|
-
}): Effect<Array<B>, E, R>;
|
|
8110
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): (elements: Iterable<A>) => Effect<Array<B>>;
|
|
7639
8111
|
/**
|
|
7640
|
-
* Filters elements of an iterable
|
|
7641
|
-
* predicate, or `Filter.FilterEffect`.
|
|
7642
|
-
*
|
|
7643
|
-
* @example
|
|
7644
|
-
* ```ts
|
|
7645
|
-
* import { Effect, Filter, Result } from "effect"
|
|
8112
|
+
* Filters and maps elements of an iterable with a `Filter`.
|
|
7646
8113
|
*
|
|
7647
|
-
*
|
|
7648
|
-
*
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
8114
|
+
* @since 4.0.0
|
|
8115
|
+
* @category Filtering
|
|
8116
|
+
*/
|
|
8117
|
+
<A, B, X>(elements: Iterable<A>, filter: Filter.Filter<NoInfer<A>, B, X>): Effect<Array<B>>;
|
|
8118
|
+
};
|
|
8119
|
+
/**
|
|
8120
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
8121
|
+
*
|
|
8122
|
+
* @since 4.0.0
|
|
8123
|
+
* @category Filtering
|
|
8124
|
+
*/
|
|
8125
|
+
export declare const filterMapEffect: {
|
|
8126
|
+
/**
|
|
8127
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
7652
8128
|
*
|
|
7653
|
-
*
|
|
7654
|
-
*
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
8129
|
+
* @since 4.0.0
|
|
8130
|
+
* @category Filtering
|
|
8131
|
+
*/
|
|
8132
|
+
<A, B, X, E, R>(filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
|
|
8133
|
+
readonly concurrency?: Concurrency | undefined;
|
|
8134
|
+
}): (elements: Iterable<A>) => Effect<Array<B>, E, R>;
|
|
8135
|
+
/**
|
|
8136
|
+
* Effectfully filters and maps elements of an iterable with a `FilterEffect`.
|
|
7658
8137
|
*
|
|
7659
|
-
* @since
|
|
8138
|
+
* @since 4.0.0
|
|
7660
8139
|
* @category Filtering
|
|
7661
8140
|
*/
|
|
7662
|
-
<A, E, R>(
|
|
8141
|
+
<A, B, X, E, R>(elements: Iterable<A>, filter: Filter.FilterEffect<NoInfer<A>, B, X, E, R>, options?: {
|
|
7663
8142
|
readonly concurrency?: Concurrency | undefined;
|
|
7664
|
-
}): Effect<Array<
|
|
8143
|
+
}): Effect<Array<B>, E, R>;
|
|
7665
8144
|
};
|
|
7666
8145
|
/**
|
|
7667
8146
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
@@ -7755,7 +8234,7 @@ export declare const filterOrElse: {
|
|
|
7755
8234
|
* @since 2.0.0
|
|
7756
8235
|
* @category Filtering
|
|
7757
8236
|
*/
|
|
7758
|
-
<A,
|
|
8237
|
+
<A, C, E2, R2>(predicate: Predicate.Predicate<NoInfer<A>>, orElse: (a: NoInfer<A>) => Effect<C, E2, R2>): <E, R>(self: Effect<A, E, R>) => Effect<A | C, E2 | E, R2 | R>;
|
|
7759
8238
|
/**
|
|
7760
8239
|
* Filters an effect, providing an alternative effect if the predicate fails.
|
|
7761
8240
|
*
|
|
@@ -7817,7 +8296,29 @@ export declare const filterOrElse: {
|
|
|
7817
8296
|
* @since 2.0.0
|
|
7818
8297
|
* @category Filtering
|
|
7819
8298
|
*/
|
|
7820
|
-
<A, E, R,
|
|
8299
|
+
<A, E, R, C, E2, R2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>, orElse: (a: NoInfer<A>) => Effect<C, E2, R2>): Effect<A | C, E | E2, R | R2>;
|
|
8300
|
+
};
|
|
8301
|
+
/**
|
|
8302
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8303
|
+
*
|
|
8304
|
+
* @since 4.0.0
|
|
8305
|
+
* @category Filtering
|
|
8306
|
+
*/
|
|
8307
|
+
export declare const filterMapOrElse: {
|
|
8308
|
+
/**
|
|
8309
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8310
|
+
*
|
|
8311
|
+
* @since 4.0.0
|
|
8312
|
+
* @category Filtering
|
|
8313
|
+
*/
|
|
8314
|
+
<A, B, X, C, E2, R2>(filter: Filter.Filter<NoInfer<A>, B, X>, orElse: (x: X) => Effect<C, E2, R2>): <E, R>(self: Effect<A, E, R>) => Effect<B | C, E2 | E, R2 | R>;
|
|
8315
|
+
/**
|
|
8316
|
+
* Filters an effect with a `Filter`, providing an alternative effect on failure.
|
|
8317
|
+
*
|
|
8318
|
+
* @since 4.0.0
|
|
8319
|
+
* @category Filtering
|
|
8320
|
+
*/
|
|
8321
|
+
<A, E, R, B, X, C, E2, R2>(self: Effect<A, E, R>, filter: Filter.Filter<NoInfer<A>, B, X>, orElse: (x: X) => Effect<C, E2, R2>): Effect<B | C, E | E2, R | R2>;
|
|
7821
8322
|
};
|
|
7822
8323
|
/**
|
|
7823
8324
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
@@ -7938,7 +8439,7 @@ export declare const filterOrFail: {
|
|
|
7938
8439
|
* @since 2.0.0
|
|
7939
8440
|
* @category Filtering
|
|
7940
8441
|
*/
|
|
7941
|
-
<A, B
|
|
8442
|
+
<A, B extends A>(refinement: Predicate.Refinement<NoInfer<A>, B>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
|
|
7942
8443
|
/**
|
|
7943
8444
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
7944
8445
|
*
|
|
@@ -7968,7 +8469,7 @@ export declare const filterOrFail: {
|
|
|
7968
8469
|
* @since 2.0.0
|
|
7969
8470
|
* @category Filtering
|
|
7970
8471
|
*/
|
|
7971
|
-
<A
|
|
8472
|
+
<A>(predicate: Predicate.Predicate<NoInfer<A>>): <E, R>(self: Effect<A, E, R>) => Effect<A, Cause.NoSuchElementError | E, R>;
|
|
7972
8473
|
/**
|
|
7973
8474
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
7974
8475
|
*
|
|
@@ -7998,7 +8499,7 @@ export declare const filterOrFail: {
|
|
|
7998
8499
|
* @since 2.0.0
|
|
7999
8500
|
* @category Filtering
|
|
8000
8501
|
*/
|
|
8001
|
-
<A
|
|
8502
|
+
<A, E, R, E2, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>, orFailWith: (a: NoInfer<A>) => E2): Effect<B, E2 | E, R>;
|
|
8002
8503
|
/**
|
|
8003
8504
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8004
8505
|
*
|
|
@@ -8028,7 +8529,7 @@ export declare const filterOrFail: {
|
|
|
8028
8529
|
* @since 2.0.0
|
|
8029
8530
|
* @category Filtering
|
|
8030
8531
|
*/
|
|
8031
|
-
<A,
|
|
8532
|
+
<A, E, R, E2>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>, orFailWith: (a: NoInfer<A>) => E2): Effect<A, E2 | E, R>;
|
|
8032
8533
|
/**
|
|
8033
8534
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8034
8535
|
*
|
|
@@ -8058,7 +8559,7 @@ export declare const filterOrFail: {
|
|
|
8058
8559
|
* @since 2.0.0
|
|
8059
8560
|
* @category Filtering
|
|
8060
8561
|
*/
|
|
8061
|
-
<A, E, R,
|
|
8562
|
+
<A, E, R, B extends A>(self: Effect<A, E, R>, refinement: Predicate.Refinement<NoInfer<A>, B>): Effect<B, E | Cause.NoSuchElementError, R>;
|
|
8062
8563
|
/**
|
|
8063
8564
|
* Filters an effect, failing with a custom error if the predicate fails.
|
|
8064
8565
|
*
|
|
@@ -8088,127 +8589,43 @@ export declare const filterOrFail: {
|
|
|
8088
8589
|
* @since 2.0.0
|
|
8089
8590
|
* @category Filtering
|
|
8090
8591
|
*/
|
|
8091
|
-
<A, E, R
|
|
8592
|
+
<A, E, R>(self: Effect<A, E, R>, predicate: Predicate.Predicate<NoInfer<A>>): Effect<A, E | Cause.NoSuchElementError, R>;
|
|
8593
|
+
};
|
|
8594
|
+
/**
|
|
8595
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8596
|
+
*
|
|
8597
|
+
* @since 4.0.0
|
|
8598
|
+
* @category Filtering
|
|
8599
|
+
*/
|
|
8600
|
+
export declare const filterMapOrFail: {
|
|
8092
8601
|
/**
|
|
8093
|
-
* Filters an effect
|
|
8094
|
-
*
|
|
8095
|
-
* **Details**
|
|
8096
|
-
*
|
|
8097
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8098
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8099
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8100
|
-
*
|
|
8101
|
-
* @example
|
|
8102
|
-
* ```ts
|
|
8103
|
-
* import { Effect } from "effect"
|
|
8104
|
-
*
|
|
8105
|
-
* // An effect that produces a number
|
|
8106
|
-
* const program = Effect.succeed(5)
|
|
8107
|
-
*
|
|
8108
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8109
|
-
* const filtered = Effect.filterOrFail(
|
|
8110
|
-
* program,
|
|
8111
|
-
* (n) => n % 2 === 0,
|
|
8112
|
-
* (n) => `Expected even number, got ${n}`
|
|
8113
|
-
* )
|
|
8114
|
-
*
|
|
8115
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8116
|
-
* ```
|
|
8602
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8117
8603
|
*
|
|
8118
|
-
* @since
|
|
8604
|
+
* @since 4.0.0
|
|
8119
8605
|
* @category Filtering
|
|
8120
8606
|
*/
|
|
8121
|
-
<A,
|
|
8607
|
+
<A, B, X, E2>(filter: Filter.Filter<NoInfer<A>, B, X>, orFailWith: (x: X) => E2): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R>;
|
|
8122
8608
|
/**
|
|
8123
|
-
* Filters an effect
|
|
8124
|
-
*
|
|
8125
|
-
* **Details**
|
|
8126
|
-
*
|
|
8127
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8128
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8129
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8130
|
-
*
|
|
8131
|
-
* @example
|
|
8132
|
-
* ```ts
|
|
8133
|
-
* import { Effect } from "effect"
|
|
8609
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8134
8610
|
*
|
|
8135
|
-
*
|
|
8136
|
-
* const program = Effect.succeed(5)
|
|
8137
|
-
*
|
|
8138
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8139
|
-
* const filtered = Effect.filterOrFail(
|
|
8140
|
-
* program,
|
|
8141
|
-
* (n) => n % 2 === 0,
|
|
8142
|
-
* (n) => `Expected even number, got ${n}`
|
|
8143
|
-
* )
|
|
8144
|
-
*
|
|
8145
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8146
|
-
* ```
|
|
8147
|
-
*
|
|
8148
|
-
* @since 2.0.0
|
|
8611
|
+
* @since 4.0.0
|
|
8149
8612
|
* @category Filtering
|
|
8150
8613
|
*/
|
|
8151
|
-
<A,
|
|
8614
|
+
<A, B, X>(filter: Filter.Filter<NoInfer<A>, B, X>): <E, R>(self: Effect<A, E, R>) => Effect<B, Cause.NoSuchElementError | E, R>;
|
|
8152
8615
|
/**
|
|
8153
|
-
* Filters an effect
|
|
8154
|
-
*
|
|
8155
|
-
* **Details**
|
|
8156
|
-
*
|
|
8157
|
-
* This function applies a predicate to the result of an effect. If the
|
|
8158
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8159
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8160
|
-
*
|
|
8161
|
-
* @example
|
|
8162
|
-
* ```ts
|
|
8163
|
-
* import { Effect } from "effect"
|
|
8164
|
-
*
|
|
8165
|
-
* // An effect that produces a number
|
|
8166
|
-
* const program = Effect.succeed(5)
|
|
8167
|
-
*
|
|
8168
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8169
|
-
* const filtered = Effect.filterOrFail(
|
|
8170
|
-
* program,
|
|
8171
|
-
* (n) => n % 2 === 0,
|
|
8172
|
-
* (n) => `Expected even number, got ${n}`
|
|
8173
|
-
* )
|
|
8174
|
-
*
|
|
8175
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8176
|
-
* ```
|
|
8616
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8177
8617
|
*
|
|
8178
|
-
* @since
|
|
8618
|
+
* @since 4.0.0
|
|
8179
8619
|
* @category Filtering
|
|
8180
8620
|
*/
|
|
8181
|
-
<A, E, R>(self: Effect<A, E, R>,
|
|
8621
|
+
<A, E, R, B, X, E2>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>, orFailWith: (x: X) => E2): Effect<B, E2 | E, R>;
|
|
8182
8622
|
/**
|
|
8183
|
-
* Filters an effect
|
|
8184
|
-
*
|
|
8185
|
-
* **Details**
|
|
8623
|
+
* Filters an effect with a `Filter`, failing when the filter fails.
|
|
8186
8624
|
*
|
|
8187
|
-
*
|
|
8188
|
-
* predicate evaluates to `false`, the effect fails with either a custom
|
|
8189
|
-
* error (if `orFailWith` is provided) or a `NoSuchElementError`.
|
|
8190
|
-
*
|
|
8191
|
-
* @example
|
|
8192
|
-
* ```ts
|
|
8193
|
-
* import { Effect } from "effect"
|
|
8194
|
-
*
|
|
8195
|
-
* // An effect that produces a number
|
|
8196
|
-
* const program = Effect.succeed(5)
|
|
8197
|
-
*
|
|
8198
|
-
* // Filter for even numbers, fail for odd numbers
|
|
8199
|
-
* const filtered = Effect.filterOrFail(
|
|
8200
|
-
* program,
|
|
8201
|
-
* (n) => n % 2 === 0,
|
|
8202
|
-
* (n) => `Expected even number, got ${n}`
|
|
8203
|
-
* )
|
|
8204
|
-
*
|
|
8205
|
-
* // Result: Effect.fail("Expected even number, got 5")
|
|
8206
|
-
* ```
|
|
8207
|
-
*
|
|
8208
|
-
* @since 2.0.0
|
|
8625
|
+
* @since 4.0.0
|
|
8209
8626
|
* @category Filtering
|
|
8210
8627
|
*/
|
|
8211
|
-
<A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B,
|
|
8628
|
+
<A, E, R, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<A, B, X>): Effect<B, Cause.NoSuchElementError | E, R>;
|
|
8212
8629
|
};
|
|
8213
8630
|
/**
|
|
8214
8631
|
* Conditionally executes an effect based on a boolean condition.
|
|
@@ -8349,9 +8766,11 @@ export declare const when: {
|
|
|
8349
8766
|
* @example
|
|
8350
8767
|
* ```ts
|
|
8351
8768
|
* // Title: Handling Both Success and Failure Cases
|
|
8352
|
-
* import { Effect } from "effect"
|
|
8769
|
+
* import { Data, Effect } from "effect"
|
|
8770
|
+
*
|
|
8771
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
8353
8772
|
*
|
|
8354
|
-
* const success: Effect.Effect<number,
|
|
8773
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
8355
8774
|
*
|
|
8356
8775
|
* const program1 = Effect.match(success, {
|
|
8357
8776
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -8362,8 +8781,8 @@ export declare const when: {
|
|
|
8362
8781
|
* Effect.runPromise(program1).then(console.log)
|
|
8363
8782
|
* // Output: "success: 42"
|
|
8364
8783
|
*
|
|
8365
|
-
* const failure: Effect.Effect<number,
|
|
8366
|
-
* new
|
|
8784
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
8785
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
8367
8786
|
* )
|
|
8368
8787
|
*
|
|
8369
8788
|
* const program2 = Effect.match(failure, {
|
|
@@ -8401,9 +8820,11 @@ export declare const match: {
|
|
|
8401
8820
|
* @example
|
|
8402
8821
|
* ```ts
|
|
8403
8822
|
* // Title: Handling Both Success and Failure Cases
|
|
8404
|
-
* import { Effect } from "effect"
|
|
8823
|
+
* import { Data, Effect } from "effect"
|
|
8405
8824
|
*
|
|
8406
|
-
*
|
|
8825
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
8826
|
+
*
|
|
8827
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
8407
8828
|
*
|
|
8408
8829
|
* const program1 = Effect.match(success, {
|
|
8409
8830
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -8414,8 +8835,8 @@ export declare const match: {
|
|
|
8414
8835
|
* Effect.runPromise(program1).then(console.log)
|
|
8415
8836
|
* // Output: "success: 42"
|
|
8416
8837
|
*
|
|
8417
|
-
* const failure: Effect.Effect<number,
|
|
8418
|
-
* new
|
|
8838
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
8839
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
8419
8840
|
* )
|
|
8420
8841
|
*
|
|
8421
8842
|
* const program2 = Effect.match(failure, {
|
|
@@ -8456,9 +8877,11 @@ export declare const match: {
|
|
|
8456
8877
|
* @example
|
|
8457
8878
|
* ```ts
|
|
8458
8879
|
* // Title: Handling Both Success and Failure Cases
|
|
8459
|
-
* import { Effect } from "effect"
|
|
8880
|
+
* import { Data, Effect } from "effect"
|
|
8881
|
+
*
|
|
8882
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
8460
8883
|
*
|
|
8461
|
-
* const success: Effect.Effect<number,
|
|
8884
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
8462
8885
|
*
|
|
8463
8886
|
* const program1 = Effect.match(success, {
|
|
8464
8887
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -8469,8 +8892,8 @@ export declare const match: {
|
|
|
8469
8892
|
* Effect.runPromise(program1).then(console.log)
|
|
8470
8893
|
* // Output: "success: 42"
|
|
8471
8894
|
*
|
|
8472
|
-
* const failure: Effect.Effect<number,
|
|
8473
|
-
* new
|
|
8895
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
8896
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
8474
8897
|
* )
|
|
8475
8898
|
*
|
|
8476
8899
|
* const program2 = Effect.match(failure, {
|
|
@@ -8872,9 +9295,11 @@ export declare const matchCauseEffectEager: {
|
|
|
8872
9295
|
*
|
|
8873
9296
|
* @example
|
|
8874
9297
|
* ```ts
|
|
8875
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
9298
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
8876
9299
|
*
|
|
8877
|
-
*
|
|
9300
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
9301
|
+
*
|
|
9302
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
8878
9303
|
*
|
|
8879
9304
|
* const program = Effect.matchCauseEffect(task, {
|
|
8880
9305
|
* onFailure: (cause) =>
|
|
@@ -8924,9 +9349,11 @@ export declare const matchCauseEffect: {
|
|
|
8924
9349
|
*
|
|
8925
9350
|
* @example
|
|
8926
9351
|
* ```ts
|
|
8927
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
9352
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
9353
|
+
*
|
|
9354
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
8928
9355
|
*
|
|
8929
|
-
* const task = Effect.fail(new
|
|
9356
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
8930
9357
|
*
|
|
8931
9358
|
* const program = Effect.matchCauseEffect(task, {
|
|
8932
9359
|
* onFailure: (cause) =>
|
|
@@ -8979,9 +9406,11 @@ export declare const matchCauseEffect: {
|
|
|
8979
9406
|
*
|
|
8980
9407
|
* @example
|
|
8981
9408
|
* ```ts
|
|
8982
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
9409
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
8983
9410
|
*
|
|
8984
|
-
*
|
|
9411
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
9412
|
+
*
|
|
9413
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
8985
9414
|
*
|
|
8986
9415
|
* const program = Effect.matchCauseEffect(task, {
|
|
8987
9416
|
* onFailure: (cause) =>
|
|
@@ -9041,11 +9470,13 @@ export declare const matchCauseEffect: {
|
|
|
9041
9470
|
* @example
|
|
9042
9471
|
* ```ts
|
|
9043
9472
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9044
|
-
* import { Effect } from "effect"
|
|
9473
|
+
* import { Data, Effect } from "effect"
|
|
9474
|
+
*
|
|
9475
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9045
9476
|
*
|
|
9046
|
-
* const success: Effect.Effect<number,
|
|
9047
|
-
* const failure: Effect.Effect<number,
|
|
9048
|
-
* new
|
|
9477
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9478
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9479
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9049
9480
|
* )
|
|
9050
9481
|
*
|
|
9051
9482
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9101,11 +9532,13 @@ export declare const matchEffect: {
|
|
|
9101
9532
|
* @example
|
|
9102
9533
|
* ```ts
|
|
9103
9534
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9104
|
-
* import { Effect } from "effect"
|
|
9535
|
+
* import { Data, Effect } from "effect"
|
|
9105
9536
|
*
|
|
9106
|
-
*
|
|
9107
|
-
*
|
|
9108
|
-
*
|
|
9537
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9538
|
+
*
|
|
9539
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9540
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9541
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9109
9542
|
* )
|
|
9110
9543
|
*
|
|
9111
9544
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9164,11 +9597,13 @@ export declare const matchEffect: {
|
|
|
9164
9597
|
* @example
|
|
9165
9598
|
* ```ts
|
|
9166
9599
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9167
|
-
* import { Effect } from "effect"
|
|
9600
|
+
* import { Data, Effect } from "effect"
|
|
9601
|
+
*
|
|
9602
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9168
9603
|
*
|
|
9169
|
-
* const success: Effect.Effect<number,
|
|
9170
|
-
* const failure: Effect.Effect<number,
|
|
9171
|
-
* new
|
|
9604
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9605
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9606
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9172
9607
|
* )
|
|
9173
9608
|
*
|
|
9174
9609
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9297,7 +9732,7 @@ export declare const isSuccess: <A, E, R>(self: Effect<A, E, R>) => Effect<boole
|
|
|
9297
9732
|
* @since 2.0.0
|
|
9298
9733
|
* @category Environment
|
|
9299
9734
|
*/
|
|
9300
|
-
export declare const services: <R>() => Effect<ServiceMap.ServiceMap<R>, never, R>;
|
|
9735
|
+
export declare const services: <R = never>() => Effect<ServiceMap.ServiceMap<R>, never, R>;
|
|
9301
9736
|
/**
|
|
9302
9737
|
* Transforms the current service map using the provided function.
|
|
9303
9738
|
*
|
|
@@ -9359,7 +9794,7 @@ export declare const servicesWith: <R, A, E, R2>(f: (services: ServiceMap.Servic
|
|
|
9359
9794
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
9360
9795
|
*
|
|
9361
9796
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9362
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9797
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9363
9798
|
* })
|
|
9364
9799
|
*
|
|
9365
9800
|
* const program = Effect.gen(function*() {
|
|
@@ -9393,7 +9828,7 @@ export declare const provide: {
|
|
|
9393
9828
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
9394
9829
|
*
|
|
9395
9830
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9396
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9831
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9397
9832
|
* })
|
|
9398
9833
|
*
|
|
9399
9834
|
* const program = Effect.gen(function*() {
|
|
@@ -9429,7 +9864,7 @@ export declare const provide: {
|
|
|
9429
9864
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
9430
9865
|
*
|
|
9431
9866
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9432
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9867
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9433
9868
|
* })
|
|
9434
9869
|
*
|
|
9435
9870
|
* const program = Effect.gen(function*() {
|
|
@@ -9465,7 +9900,7 @@ export declare const provide: {
|
|
|
9465
9900
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
9466
9901
|
*
|
|
9467
9902
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9468
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9903
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9469
9904
|
* })
|
|
9470
9905
|
*
|
|
9471
9906
|
* const program = Effect.gen(function*() {
|
|
@@ -9499,7 +9934,7 @@ export declare const provide: {
|
|
|
9499
9934
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
9500
9935
|
*
|
|
9501
9936
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9502
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9937
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9503
9938
|
* })
|
|
9504
9939
|
*
|
|
9505
9940
|
* const program = Effect.gen(function*() {
|
|
@@ -9535,7 +9970,7 @@ export declare const provide: {
|
|
|
9535
9970
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
9536
9971
|
*
|
|
9537
9972
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9538
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
9973
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9539
9974
|
* })
|
|
9540
9975
|
*
|
|
9541
9976
|
* const program = Effect.gen(function*() {
|
|
@@ -9571,7 +10006,7 @@ export declare const provide: {
|
|
|
9571
10006
|
* const Database = ServiceMap.Service<Database>("Database")
|
|
9572
10007
|
*
|
|
9573
10008
|
* const DatabaseLive = Layer.succeed(Database)({
|
|
9574
|
-
* query: (sql: string) => Effect.succeed(`Result for: ${sql}`)
|
|
10009
|
+
* query: Effect.fn("Database.query")((sql: string) => Effect.succeed(`Result for: ${sql}`))
|
|
9575
10010
|
* })
|
|
9576
10011
|
*
|
|
9577
10012
|
* const program = Effect.gen(function*() {
|
|
@@ -9733,7 +10168,7 @@ export declare const provideServices: {
|
|
|
9733
10168
|
* @since 4.0.0
|
|
9734
10169
|
* @category ServiceMap
|
|
9735
10170
|
*/
|
|
9736
|
-
export declare const service: <I, S>(service: ServiceMap.
|
|
10171
|
+
export declare const service: <I, S>(service: ServiceMap.Key<I, S>) => Effect<S, never, I>;
|
|
9737
10172
|
/**
|
|
9738
10173
|
* Optionally accesses a service from the environment.
|
|
9739
10174
|
*
|
|
@@ -9768,7 +10203,7 @@ export declare const service: <I, S>(service: ServiceMap.Service<I, S>) => Effec
|
|
|
9768
10203
|
* @since 2.0.0
|
|
9769
10204
|
* @category ServiceMap
|
|
9770
10205
|
*/
|
|
9771
|
-
export declare const serviceOption: <I, S>(key: ServiceMap.
|
|
10206
|
+
export declare const serviceOption: <I, S>(key: ServiceMap.Key<I, S>) => Effect<Option<S>>;
|
|
9772
10207
|
/**
|
|
9773
10208
|
* Provides part of the required context while leaving the rest unchanged.
|
|
9774
10209
|
*
|
|
@@ -9950,7 +10385,7 @@ export declare const updateService: {
|
|
|
9950
10385
|
* @since 2.0.0
|
|
9951
10386
|
* @category ServiceMap
|
|
9952
10387
|
*/
|
|
9953
|
-
<I, A>(service: ServiceMap.
|
|
10388
|
+
<I, A>(service: ServiceMap.Key<I, A>, f: (value: A) => A): <XA, E, R>(self: Effect<XA, E, R>) => Effect<XA, E, R | I>;
|
|
9954
10389
|
/**
|
|
9955
10390
|
* Updates the service with the required service entry.
|
|
9956
10391
|
*
|
|
@@ -9979,7 +10414,7 @@ export declare const updateService: {
|
|
|
9979
10414
|
* @since 2.0.0
|
|
9980
10415
|
* @category ServiceMap
|
|
9981
10416
|
*/
|
|
9982
|
-
<XA, E, R, I, A>(self: Effect<XA, E, R>, service: ServiceMap.
|
|
10417
|
+
<XA, E, R, I, A>(self: Effect<XA, E, R>, service: ServiceMap.Key<I, A>, f: (value: A) => A): Effect<XA, E, R | I>;
|
|
9983
10418
|
};
|
|
9984
10419
|
/**
|
|
9985
10420
|
* The `provideService` function is used to provide an actual
|
|
@@ -10072,7 +10507,7 @@ export declare const provideService: {
|
|
|
10072
10507
|
* @since 2.0.0
|
|
10073
10508
|
* @category ServiceMap
|
|
10074
10509
|
*/
|
|
10075
|
-
<I, S>(service: ServiceMap.
|
|
10510
|
+
<I, S>(service: ServiceMap.Key<I, S>): {
|
|
10076
10511
|
/**
|
|
10077
10512
|
* The `provideService` function is used to provide an actual
|
|
10078
10513
|
* implementation for a service in the context of an effect.
|
|
@@ -10211,7 +10646,7 @@ export declare const provideService: {
|
|
|
10211
10646
|
* @since 2.0.0
|
|
10212
10647
|
* @category ServiceMap
|
|
10213
10648
|
*/
|
|
10214
|
-
<I, S>(service: ServiceMap.
|
|
10649
|
+
<I, S>(service: ServiceMap.Key<I, S>, implementation: S): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, Exclude<R, I>>;
|
|
10215
10650
|
/**
|
|
10216
10651
|
* The `provideService` function is used to provide an actual
|
|
10217
10652
|
* implementation for a service in the context of an effect.
|
|
@@ -10257,7 +10692,7 @@ export declare const provideService: {
|
|
|
10257
10692
|
* @since 2.0.0
|
|
10258
10693
|
* @category ServiceMap
|
|
10259
10694
|
*/
|
|
10260
|
-
<A, E, R, I, S>(self: Effect<A, E, R>, service: ServiceMap.
|
|
10695
|
+
<A, E, R, I, S>(self: Effect<A, E, R>, service: ServiceMap.Key<I, S>, implementation: S): Effect<A, E, Exclude<R, I>>;
|
|
10261
10696
|
};
|
|
10262
10697
|
/**
|
|
10263
10698
|
* Provides the effect with the single service it requires. If the effect
|
|
@@ -10364,7 +10799,7 @@ export declare const provideServiceEffect: {
|
|
|
10364
10799
|
* @since 2.0.0
|
|
10365
10800
|
* @category ServiceMap
|
|
10366
10801
|
*/
|
|
10367
|
-
<I, S, E2, R2>(service: ServiceMap.
|
|
10802
|
+
<I, S, E2, R2>(service: ServiceMap.Key<I, S>, acquire: Effect<S, E2, R2>): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E | E2, Exclude<R, I> | R2>;
|
|
10368
10803
|
/**
|
|
10369
10804
|
* Provides the effect with the single service it requires. If the effect
|
|
10370
10805
|
* requires more than one service use `provide` instead.
|
|
@@ -10417,7 +10852,7 @@ export declare const provideServiceEffect: {
|
|
|
10417
10852
|
* @since 2.0.0
|
|
10418
10853
|
* @category ServiceMap
|
|
10419
10854
|
*/
|
|
10420
|
-
<A, E, R, I, S, E2, R2>(self: Effect<A, E, R>, service: ServiceMap.
|
|
10855
|
+
<A, E, R, I, S, E2, R2>(self: Effect<A, E, R>, service: ServiceMap.Key<I, S>, acquire: Effect<S, E2, R2>): Effect<A, E | E2, Exclude<R, I> | R2>;
|
|
10421
10856
|
};
|
|
10422
10857
|
/**
|
|
10423
10858
|
* Sets the concurrency level for parallel operations within an effect.
|
|
@@ -10914,9 +11349,11 @@ export declare const ensuring: {
|
|
|
10914
11349
|
*
|
|
10915
11350
|
* @example
|
|
10916
11351
|
* ```ts
|
|
10917
|
-
* import { Cause, Console, Effect } from "effect"
|
|
11352
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
11353
|
+
*
|
|
11354
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
10918
11355
|
*
|
|
10919
|
-
* const task = Effect.fail(new
|
|
11356
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
10920
11357
|
*
|
|
10921
11358
|
* const program = Effect.onError(
|
|
10922
11359
|
* task,
|
|
@@ -10925,8 +11362,8 @@ export declare const ensuring: {
|
|
|
10925
11362
|
*
|
|
10926
11363
|
* Effect.runPromise(program).catch(console.error)
|
|
10927
11364
|
* // Output:
|
|
10928
|
-
* // Cleanup on error:
|
|
10929
|
-
* //
|
|
11365
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
11366
|
+
* // TaskError: Something went wrong
|
|
10930
11367
|
* ```
|
|
10931
11368
|
*
|
|
10932
11369
|
* @since 2.0.0
|
|
@@ -10939,9 +11376,11 @@ export declare const onError: {
|
|
|
10939
11376
|
*
|
|
10940
11377
|
* @example
|
|
10941
11378
|
* ```ts
|
|
10942
|
-
* import { Cause, Console, Effect } from "effect"
|
|
11379
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
11380
|
+
*
|
|
11381
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
10943
11382
|
*
|
|
10944
|
-
* const task = Effect.fail(new
|
|
11383
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
10945
11384
|
*
|
|
10946
11385
|
* const program = Effect.onError(
|
|
10947
11386
|
* task,
|
|
@@ -10950,8 +11389,8 @@ export declare const onError: {
|
|
|
10950
11389
|
*
|
|
10951
11390
|
* Effect.runPromise(program).catch(console.error)
|
|
10952
11391
|
* // Output:
|
|
10953
|
-
* // Cleanup on error:
|
|
10954
|
-
* //
|
|
11392
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
11393
|
+
* // TaskError: Something went wrong
|
|
10955
11394
|
* ```
|
|
10956
11395
|
*
|
|
10957
11396
|
* @since 2.0.0
|
|
@@ -10964,9 +11403,11 @@ export declare const onError: {
|
|
|
10964
11403
|
*
|
|
10965
11404
|
* @example
|
|
10966
11405
|
* ```ts
|
|
10967
|
-
* import { Cause, Console, Effect } from "effect"
|
|
11406
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
11407
|
+
*
|
|
11408
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
10968
11409
|
*
|
|
10969
|
-
* const task = Effect.fail(new
|
|
11410
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
10970
11411
|
*
|
|
10971
11412
|
* const program = Effect.onError(
|
|
10972
11413
|
* task,
|
|
@@ -10975,8 +11416,8 @@ export declare const onError: {
|
|
|
10975
11416
|
*
|
|
10976
11417
|
* Effect.runPromise(program).catch(console.error)
|
|
10977
11418
|
* // Output:
|
|
10978
|
-
* // Cleanup on error:
|
|
10979
|
-
* //
|
|
11419
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
11420
|
+
* // TaskError: Something went wrong
|
|
10980
11421
|
* ```
|
|
10981
11422
|
*
|
|
10982
11423
|
* @since 2.0.0
|
|
@@ -10986,7 +11427,7 @@ export declare const onError: {
|
|
|
10986
11427
|
};
|
|
10987
11428
|
/**
|
|
10988
11429
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
10989
|
-
*
|
|
11430
|
+
* provided predicate.
|
|
10990
11431
|
*
|
|
10991
11432
|
* @example
|
|
10992
11433
|
* ```ts
|
|
@@ -11010,7 +11451,7 @@ export declare const onError: {
|
|
|
11010
11451
|
export declare const onErrorIf: {
|
|
11011
11452
|
/**
|
|
11012
11453
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11013
|
-
*
|
|
11454
|
+
* provided predicate.
|
|
11014
11455
|
*
|
|
11015
11456
|
* @example
|
|
11016
11457
|
* ```ts
|
|
@@ -11031,10 +11472,10 @@ export declare const onErrorIf: {
|
|
|
11031
11472
|
* @since 4.0.0
|
|
11032
11473
|
* @category Resource Management & Finalization
|
|
11033
11474
|
*/
|
|
11034
|
-
<E,
|
|
11475
|
+
<E, XE, XR>(predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>): <A, R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
|
|
11035
11476
|
/**
|
|
11036
11477
|
* Runs the finalizer only when this effect fails and the `Cause` matches the
|
|
11037
|
-
*
|
|
11478
|
+
* provided predicate.
|
|
11038
11479
|
*
|
|
11039
11480
|
* @example
|
|
11040
11481
|
* ```ts
|
|
@@ -11055,7 +11496,29 @@ export declare const onErrorIf: {
|
|
|
11055
11496
|
* @since 4.0.0
|
|
11056
11497
|
* @category Resource Management & Finalization
|
|
11057
11498
|
*/
|
|
11058
|
-
<A, E, R, XE, XR
|
|
11499
|
+
<A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Cause.Cause<E>>, f: (cause: Cause.Cause<E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11500
|
+
};
|
|
11501
|
+
/**
|
|
11502
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
11503
|
+
*
|
|
11504
|
+
* @since 4.0.0
|
|
11505
|
+
* @category Resource Management & Finalization
|
|
11506
|
+
*/
|
|
11507
|
+
export declare const onErrorFilter: {
|
|
11508
|
+
/**
|
|
11509
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
11510
|
+
*
|
|
11511
|
+
* @since 4.0.0
|
|
11512
|
+
* @category Resource Management & Finalization
|
|
11513
|
+
*/
|
|
11514
|
+
<A, E, EB, X, XE, XR>(filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
|
|
11515
|
+
/**
|
|
11516
|
+
* Runs the finalizer only when this effect fails and the cause matches the provided `Filter`.
|
|
11517
|
+
*
|
|
11518
|
+
* @since 4.0.0
|
|
11519
|
+
* @category Resource Management & Finalization
|
|
11520
|
+
*/
|
|
11521
|
+
<A, E, R, EB, X, XE, XR>(self: Effect<A, E, R>, filter: Filter.Filter<Cause.Cause<E>, EB, X>, f: (failure: EB, cause: Cause.Cause<E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11059
11522
|
};
|
|
11060
11523
|
/**
|
|
11061
11524
|
* The low level primitive that powers `onExit`.
|
|
@@ -11149,20 +11612,20 @@ export declare const onExit: {
|
|
|
11149
11612
|
<A, E, R, XE = never, XR = never>(self: Effect<A, E, R>, f: (exit: Exit.Exit<A, E>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11150
11613
|
};
|
|
11151
11614
|
/**
|
|
11152
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11153
|
-
*
|
|
11154
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
11615
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
11616
|
+
* predicate.
|
|
11155
11617
|
*
|
|
11156
11618
|
* @example
|
|
11157
11619
|
* ```ts
|
|
11158
|
-
* import { Console, Effect, Exit
|
|
11159
|
-
*
|
|
11160
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
11620
|
+
* import { Console, Effect, Exit } from "effect"
|
|
11161
11621
|
*
|
|
11162
11622
|
* const program = Effect.onExitIf(
|
|
11163
11623
|
* Effect.succeed(42),
|
|
11164
|
-
*
|
|
11165
|
-
* (
|
|
11624
|
+
* Exit.isSuccess,
|
|
11625
|
+
* (exit) =>
|
|
11626
|
+
* Exit.isSuccess(exit)
|
|
11627
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
11628
|
+
* : Effect.void
|
|
11166
11629
|
* )
|
|
11167
11630
|
* ```
|
|
11168
11631
|
*
|
|
@@ -11171,49 +11634,71 @@ export declare const onExit: {
|
|
|
11171
11634
|
*/
|
|
11172
11635
|
export declare const onExitIf: {
|
|
11173
11636
|
/**
|
|
11174
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11175
|
-
*
|
|
11176
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
11637
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
11638
|
+
* predicate.
|
|
11177
11639
|
*
|
|
11178
11640
|
* @example
|
|
11179
11641
|
* ```ts
|
|
11180
|
-
* import { Console, Effect, Exit
|
|
11642
|
+
* import { Console, Effect, Exit } from "effect"
|
|
11643
|
+
*
|
|
11644
|
+
* const program = Effect.onExitIf(
|
|
11645
|
+
* Effect.succeed(42),
|
|
11646
|
+
* Exit.isSuccess,
|
|
11647
|
+
* (exit) =>
|
|
11648
|
+
* Exit.isSuccess(exit)
|
|
11649
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
11650
|
+
* : Effect.void
|
|
11651
|
+
* )
|
|
11652
|
+
* ```
|
|
11653
|
+
*
|
|
11654
|
+
* @since 4.0.0
|
|
11655
|
+
* @category Resource Management & Finalization
|
|
11656
|
+
*/
|
|
11657
|
+
<A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
|
|
11658
|
+
/**
|
|
11659
|
+
* Runs the cleanup effect only when the `Exit` satisfies the provided
|
|
11660
|
+
* predicate.
|
|
11181
11661
|
*
|
|
11182
|
-
*
|
|
11662
|
+
* @example
|
|
11663
|
+
* ```ts
|
|
11664
|
+
* import { Console, Effect, Exit } from "effect"
|
|
11183
11665
|
*
|
|
11184
11666
|
* const program = Effect.onExitIf(
|
|
11185
11667
|
* Effect.succeed(42),
|
|
11186
|
-
*
|
|
11187
|
-
* (
|
|
11668
|
+
* Exit.isSuccess,
|
|
11669
|
+
* (exit) =>
|
|
11670
|
+
* Exit.isSuccess(exit)
|
|
11671
|
+
* ? Console.log(`Succeeded with: ${exit.value}`)
|
|
11672
|
+
* : Effect.void
|
|
11188
11673
|
* )
|
|
11189
11674
|
* ```
|
|
11190
11675
|
*
|
|
11191
11676
|
* @since 4.0.0
|
|
11192
11677
|
* @category Resource Management & Finalization
|
|
11193
11678
|
*/
|
|
11194
|
-
<A, E, XE, XR
|
|
11679
|
+
<A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11680
|
+
};
|
|
11681
|
+
/**
|
|
11682
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
11683
|
+
*
|
|
11684
|
+
* @since 4.0.0
|
|
11685
|
+
* @category Resource Management & Finalization
|
|
11686
|
+
*/
|
|
11687
|
+
export declare const onExitFilter: {
|
|
11688
|
+
/**
|
|
11689
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
11690
|
+
*
|
|
11691
|
+
* @since 4.0.0
|
|
11692
|
+
* @category Resource Management & Finalization
|
|
11693
|
+
*/
|
|
11694
|
+
<A, E, XE, XR, B, X>(filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>, f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>;
|
|
11195
11695
|
/**
|
|
11196
|
-
* Runs the cleanup effect only when the `Exit`
|
|
11197
|
-
*
|
|
11198
|
-
* The cleanup is skipped when the filter returns `Filter.fail`.
|
|
11199
|
-
*
|
|
11200
|
-
* @example
|
|
11201
|
-
* ```ts
|
|
11202
|
-
* import { Console, Effect, Exit, Filter } from "effect"
|
|
11203
|
-
*
|
|
11204
|
-
* const exitFilter = Filter.fromPredicate(Exit.isSuccess<number, never>)
|
|
11205
|
-
*
|
|
11206
|
-
* const program = Effect.onExitIf(
|
|
11207
|
-
* Effect.succeed(42),
|
|
11208
|
-
* exitFilter,
|
|
11209
|
-
* (success) => Console.log(`Succeeded with: ${success.value}`)
|
|
11210
|
-
* )
|
|
11211
|
-
* ```
|
|
11696
|
+
* Runs the cleanup effect only when the `Exit` matches the provided `Filter`.
|
|
11212
11697
|
*
|
|
11213
11698
|
* @since 4.0.0
|
|
11214
11699
|
* @category Resource Management & Finalization
|
|
11215
11700
|
*/
|
|
11216
|
-
<A, E, R, XE, XR,
|
|
11701
|
+
<A, E, R, XE, XR, B, X>(self: Effect<A, E, R>, filter: Filter.Filter<Exit.Exit<NoInfer<A>, NoInfer<E>>, B, X>, f: (b: B, exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>;
|
|
11217
11702
|
};
|
|
11218
11703
|
/**
|
|
11219
11704
|
* Returns an effect that lazily computes a result and caches it for subsequent
|
|
@@ -11412,7 +11897,7 @@ export declare const cachedWithTTL: {
|
|
|
11412
11897
|
* @since 2.0.0
|
|
11413
11898
|
* @category Caching
|
|
11414
11899
|
*/
|
|
11415
|
-
(timeToLive: Duration.
|
|
11900
|
+
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<Effect<A, E, R>>;
|
|
11416
11901
|
/**
|
|
11417
11902
|
* Returns an effect that caches its result for a specified `Duration`,
|
|
11418
11903
|
* known as "timeToLive" (TTL).
|
|
@@ -11479,7 +11964,7 @@ export declare const cachedWithTTL: {
|
|
|
11479
11964
|
* @since 2.0.0
|
|
11480
11965
|
* @category Caching
|
|
11481
11966
|
*/
|
|
11482
|
-
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.
|
|
11967
|
+
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<Effect<A, E, R>>;
|
|
11483
11968
|
};
|
|
11484
11969
|
/**
|
|
11485
11970
|
* Caches an effect's result for a specified duration and allows manual
|
|
@@ -11620,7 +12105,7 @@ export declare const cachedInvalidateWithTTL: {
|
|
|
11620
12105
|
* @since 2.0.0
|
|
11621
12106
|
* @category Caching
|
|
11622
12107
|
*/
|
|
11623
|
-
(timeToLive: Duration.
|
|
12108
|
+
(timeToLive: Duration.Input): <A, E, R>(self: Effect<A, E, R>) => Effect<[Effect<A, E, R>, Effect<void>]>;
|
|
11624
12109
|
/**
|
|
11625
12110
|
* Caches an effect's result for a specified duration and allows manual
|
|
11626
12111
|
* invalidation before expiration.
|
|
@@ -11690,7 +12175,7 @@ export declare const cachedInvalidateWithTTL: {
|
|
|
11690
12175
|
* @since 2.0.0
|
|
11691
12176
|
* @category Caching
|
|
11692
12177
|
*/
|
|
11693
|
-
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.
|
|
12178
|
+
<A, E, R>(self: Effect<A, E, R>, timeToLive: Duration.Input): Effect<[Effect<A, E, R>, Effect<void>]>;
|
|
11694
12179
|
};
|
|
11695
12180
|
/**
|
|
11696
12181
|
* Returns an effect that is immediately interrupted.
|
|
@@ -11700,8 +12185,8 @@ export declare const cachedInvalidateWithTTL: {
|
|
|
11700
12185
|
* import { Effect } from "effect"
|
|
11701
12186
|
*
|
|
11702
12187
|
* const program = Effect.gen(function*() {
|
|
11703
|
-
* yield* Effect.interrupt
|
|
11704
|
-
* yield* Effect.succeed("This won't execute")
|
|
12188
|
+
* return yield* Effect.interrupt
|
|
12189
|
+
* yield* Effect.succeed("This won't execute and is unreachable")
|
|
11705
12190
|
* })
|
|
11706
12191
|
*
|
|
11707
12192
|
* Effect.runPromise(program).catch(console.error)
|
|
@@ -11890,232 +12375,6 @@ export declare const uninterruptibleMask: <A, E, R>(f: (restore: <AX, EX, RX>(ef
|
|
|
11890
12375
|
* @category Interruption
|
|
11891
12376
|
*/
|
|
11892
12377
|
export declare const interruptibleMask: <A, E, R>(f: (restore: <AX, EX, RX>(effect: Effect<AX, EX, RX>) => Effect<AX, EX, RX>) => Effect<A, E, R>) => Effect<A, E, R>;
|
|
11893
|
-
/**
|
|
11894
|
-
* @category Semaphore
|
|
11895
|
-
* @since 2.0.0
|
|
11896
|
-
* @example
|
|
11897
|
-
* ```ts
|
|
11898
|
-
* import { Effect } from "effect"
|
|
11899
|
-
*
|
|
11900
|
-
* // Create and use a semaphore for controlling concurrent access
|
|
11901
|
-
* const program = Effect.gen(function*() {
|
|
11902
|
-
* const semaphore = yield* Effect.makeSemaphore(2)
|
|
11903
|
-
*
|
|
11904
|
-
* return yield* semaphore.withPermits(1)(
|
|
11905
|
-
* Effect.succeed("Resource accessed")
|
|
11906
|
-
* )
|
|
11907
|
-
* })
|
|
11908
|
-
* ```
|
|
11909
|
-
*/
|
|
11910
|
-
export interface Semaphore {
|
|
11911
|
-
/**
|
|
11912
|
-
* Adjusts the number of permits available in the semaphore.
|
|
11913
|
-
*/
|
|
11914
|
-
resize(permits: number): Effect<void>;
|
|
11915
|
-
/**
|
|
11916
|
-
* Runs an effect with the given number of permits and releases the permits
|
|
11917
|
-
* when the effect completes.
|
|
11918
|
-
*
|
|
11919
|
-
* **Details**
|
|
11920
|
-
*
|
|
11921
|
-
* This function acquires the specified number of permits before executing
|
|
11922
|
-
* the provided effect. Once the effect finishes, the permits are released.
|
|
11923
|
-
* If insufficient permits are available, the function will wait until they
|
|
11924
|
-
* are released by other tasks.
|
|
11925
|
-
*/
|
|
11926
|
-
withPermits(permits: number): <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
|
|
11927
|
-
/**
|
|
11928
|
-
* Runs an effect with the given number of permits and releases the permits
|
|
11929
|
-
* when the effect completes.
|
|
11930
|
-
*
|
|
11931
|
-
* **Details**
|
|
11932
|
-
*
|
|
11933
|
-
* This function acquires the specified number of permits before executing
|
|
11934
|
-
* the provided effect. Once the effect finishes, the permits are released.
|
|
11935
|
-
* If insufficient permits are available, the function will wait until they
|
|
11936
|
-
* are released by other tasks.
|
|
11937
|
-
*/
|
|
11938
|
-
withPermit<A, E, R>(self: Effect<A, E, R>): Effect<A, E, R>;
|
|
11939
|
-
/**
|
|
11940
|
-
* Runs an effect only if the specified number of permits are immediately
|
|
11941
|
-
* available.
|
|
11942
|
-
*
|
|
11943
|
-
* **Details**
|
|
11944
|
-
*
|
|
11945
|
-
* This function attempts to acquire the specified number of permits. If they
|
|
11946
|
-
* are available, it runs the effect and releases the permits after the effect
|
|
11947
|
-
* completes. If permits are not available, the effect does not execute, and
|
|
11948
|
-
* the result is `Option.none`.
|
|
11949
|
-
*/
|
|
11950
|
-
withPermitsIfAvailable(permits: number): <A, E, R>(self: Effect<A, E, R>) => Effect<Option<A>, E, R>;
|
|
11951
|
-
/**
|
|
11952
|
-
* Acquires the specified number of permits and returns the resulting
|
|
11953
|
-
* available permits, suspending the task if they are not yet available.
|
|
11954
|
-
* Concurrent pending `take` calls are processed in a first-in, first-out manner.
|
|
11955
|
-
*/
|
|
11956
|
-
take(permits: number): Effect<number>;
|
|
11957
|
-
/**
|
|
11958
|
-
* Releases the specified number of permits and returns the resulting
|
|
11959
|
-
* available permits.
|
|
11960
|
-
*/
|
|
11961
|
-
release(permits: number): Effect<number>;
|
|
11962
|
-
/**
|
|
11963
|
-
* Releases all permits held by this semaphore and returns the resulting available permits.
|
|
11964
|
-
*/
|
|
11965
|
-
releaseAll: Effect<number>;
|
|
11966
|
-
}
|
|
11967
|
-
/**
|
|
11968
|
-
* Unsafely creates a new Semaphore.
|
|
11969
|
-
*
|
|
11970
|
-
* @example
|
|
11971
|
-
* ```ts
|
|
11972
|
-
* import { Effect } from "effect"
|
|
11973
|
-
*
|
|
11974
|
-
* const semaphore = Effect.makeSemaphoreUnsafe(3)
|
|
11975
|
-
*
|
|
11976
|
-
* const task = (id: number) =>
|
|
11977
|
-
* semaphore.withPermits(1)(
|
|
11978
|
-
* Effect.gen(function*() {
|
|
11979
|
-
* yield* Effect.log(`Task ${id} started`)
|
|
11980
|
-
* yield* Effect.sleep("1 second")
|
|
11981
|
-
* yield* Effect.log(`Task ${id} completed`)
|
|
11982
|
-
* })
|
|
11983
|
-
* )
|
|
11984
|
-
*
|
|
11985
|
-
* // Only 3 tasks can run concurrently
|
|
11986
|
-
* const program = Effect.all([
|
|
11987
|
-
* task(1),
|
|
11988
|
-
* task(2),
|
|
11989
|
-
* task(3),
|
|
11990
|
-
* task(4),
|
|
11991
|
-
* task(5)
|
|
11992
|
-
* ], { concurrency: "unbounded" })
|
|
11993
|
-
* ```
|
|
11994
|
-
*
|
|
11995
|
-
* @since 2.0.0
|
|
11996
|
-
* @category Semaphore
|
|
11997
|
-
*/
|
|
11998
|
-
export declare const makeSemaphoreUnsafe: (permits: number) => Semaphore;
|
|
11999
|
-
/**
|
|
12000
|
-
* Creates a new Semaphore.
|
|
12001
|
-
*
|
|
12002
|
-
* @example
|
|
12003
|
-
* ```ts
|
|
12004
|
-
* import { Effect } from "effect"
|
|
12005
|
-
*
|
|
12006
|
-
* const program = Effect.gen(function*() {
|
|
12007
|
-
* const semaphore = yield* Effect.makeSemaphore(2)
|
|
12008
|
-
*
|
|
12009
|
-
* const task = (id: number) =>
|
|
12010
|
-
* semaphore.withPermits(1)(
|
|
12011
|
-
* Effect.gen(function*() {
|
|
12012
|
-
* yield* Effect.log(`Task ${id} acquired permit`)
|
|
12013
|
-
* yield* Effect.sleep("1 second")
|
|
12014
|
-
* yield* Effect.log(`Task ${id} releasing permit`)
|
|
12015
|
-
* })
|
|
12016
|
-
* )
|
|
12017
|
-
*
|
|
12018
|
-
* // Run 4 tasks, but only 2 can run concurrently
|
|
12019
|
-
* yield* Effect.all([task(1), task(2), task(3), task(4)])
|
|
12020
|
-
* })
|
|
12021
|
-
* ```
|
|
12022
|
-
*
|
|
12023
|
-
* @since 2.0.0
|
|
12024
|
-
* @category Semaphore
|
|
12025
|
-
*/
|
|
12026
|
-
export declare const makeSemaphore: (permits: number) => Effect<Semaphore>;
|
|
12027
|
-
/**
|
|
12028
|
-
* @category Latch
|
|
12029
|
-
* @since 3.8.0
|
|
12030
|
-
* @example
|
|
12031
|
-
* ```ts
|
|
12032
|
-
* import { Effect } from "effect"
|
|
12033
|
-
*
|
|
12034
|
-
* // Create and use a latch for coordination between fibers
|
|
12035
|
-
* const program = Effect.gen(function*() {
|
|
12036
|
-
* const latch = yield* Effect.makeLatch()
|
|
12037
|
-
*
|
|
12038
|
-
* // Wait for the latch to be opened
|
|
12039
|
-
* yield* latch.await
|
|
12040
|
-
*
|
|
12041
|
-
* return "Latch was opened!"
|
|
12042
|
-
* })
|
|
12043
|
-
* ```
|
|
12044
|
-
*/
|
|
12045
|
-
export interface Latch {
|
|
12046
|
-
/** open the latch, releasing all fibers waiting on it */
|
|
12047
|
-
readonly open: Effect<boolean>;
|
|
12048
|
-
/** open the latch, releasing all fibers waiting on it */
|
|
12049
|
-
readonly openUnsafe: () => boolean;
|
|
12050
|
-
/** release all fibers waiting on the latch, without opening it */
|
|
12051
|
-
readonly release: Effect<boolean>;
|
|
12052
|
-
/** wait for the latch to be opened */
|
|
12053
|
-
readonly await: Effect<void>;
|
|
12054
|
-
/** close the latch */
|
|
12055
|
-
readonly close: Effect<boolean>;
|
|
12056
|
-
/** close the latch */
|
|
12057
|
-
readonly closeUnsafe: () => boolean;
|
|
12058
|
-
/** only run the given effect when the latch is open */
|
|
12059
|
-
readonly whenOpen: <A, E, R>(self: Effect<A, E, R>) => Effect<A, E, R>;
|
|
12060
|
-
}
|
|
12061
|
-
/**
|
|
12062
|
-
* Creates a new Latch.
|
|
12063
|
-
*
|
|
12064
|
-
* @example
|
|
12065
|
-
* ```ts
|
|
12066
|
-
* import { Effect } from "effect"
|
|
12067
|
-
*
|
|
12068
|
-
* const latch = Effect.makeLatchUnsafe(false)
|
|
12069
|
-
*
|
|
12070
|
-
* const waiter = Effect.gen(function*() {
|
|
12071
|
-
* yield* Effect.log("Waiting for latch to open...")
|
|
12072
|
-
* yield* latch.await
|
|
12073
|
-
* yield* Effect.log("Latch opened! Continuing...")
|
|
12074
|
-
* })
|
|
12075
|
-
*
|
|
12076
|
-
* const opener = Effect.gen(function*() {
|
|
12077
|
-
* yield* Effect.sleep("2 seconds")
|
|
12078
|
-
* yield* Effect.log("Opening latch...")
|
|
12079
|
-
* yield* latch.open
|
|
12080
|
-
* })
|
|
12081
|
-
*
|
|
12082
|
-
* const program = Effect.all([waiter, opener])
|
|
12083
|
-
* ```
|
|
12084
|
-
*
|
|
12085
|
-
* @category Latch
|
|
12086
|
-
* @since 3.8.0
|
|
12087
|
-
*/
|
|
12088
|
-
export declare const makeLatchUnsafe: (open?: boolean | undefined) => Latch;
|
|
12089
|
-
/**
|
|
12090
|
-
* Creates a new Latch.
|
|
12091
|
-
*
|
|
12092
|
-
* @example
|
|
12093
|
-
* ```ts
|
|
12094
|
-
* import { Effect } from "effect"
|
|
12095
|
-
*
|
|
12096
|
-
* const program = Effect.gen(function*() {
|
|
12097
|
-
* const latch = yield* Effect.makeLatch(false)
|
|
12098
|
-
*
|
|
12099
|
-
* const waiter = Effect.gen(function*() {
|
|
12100
|
-
* yield* Effect.log("Waiting for latch to open...")
|
|
12101
|
-
* yield* latch.await
|
|
12102
|
-
* yield* Effect.log("Latch opened! Continuing...")
|
|
12103
|
-
* })
|
|
12104
|
-
*
|
|
12105
|
-
* const opener = Effect.gen(function*() {
|
|
12106
|
-
* yield* Effect.sleep("2 seconds")
|
|
12107
|
-
* yield* Effect.log("Opening latch...")
|
|
12108
|
-
* yield* latch.open
|
|
12109
|
-
* })
|
|
12110
|
-
*
|
|
12111
|
-
* yield* Effect.all([waiter, opener])
|
|
12112
|
-
* })
|
|
12113
|
-
* ```
|
|
12114
|
-
*
|
|
12115
|
-
* @category Latch
|
|
12116
|
-
* @since 3.8.0
|
|
12117
|
-
*/
|
|
12118
|
-
export declare const makeLatch: (open?: boolean | undefined) => Effect<Latch>;
|
|
12119
12378
|
/**
|
|
12120
12379
|
* @since 2.0.0
|
|
12121
12380
|
* @category Repetition / Recursion
|
|
@@ -12696,7 +12955,7 @@ export declare const repeat: {
|
|
|
12696
12955
|
* attempt++
|
|
12697
12956
|
* if (attempt <= 2) {
|
|
12698
12957
|
* yield* Console.log(`Attempt ${attempt} failed`)
|
|
12699
|
-
* yield* Effect.fail(`Error ${attempt}`)
|
|
12958
|
+
* return yield* Effect.fail(`Error ${attempt}`)
|
|
12700
12959
|
* }
|
|
12701
12960
|
* yield* Console.log(`Attempt ${attempt} succeeded`)
|
|
12702
12961
|
* return "success"
|
|
@@ -12746,7 +13005,7 @@ export declare const repeatOrElse: {
|
|
|
12746
13005
|
* attempt++
|
|
12747
13006
|
* if (attempt <= 2) {
|
|
12748
13007
|
* yield* Console.log(`Attempt ${attempt} failed`)
|
|
12749
|
-
* yield* Effect.fail(`Error ${attempt}`)
|
|
13008
|
+
* return yield* Effect.fail(`Error ${attempt}`)
|
|
12750
13009
|
* }
|
|
12751
13010
|
* yield* Console.log(`Attempt ${attempt} succeeded`)
|
|
12752
13011
|
* return "success"
|
|
@@ -12796,7 +13055,7 @@ export declare const repeatOrElse: {
|
|
|
12796
13055
|
* attempt++
|
|
12797
13056
|
* if (attempt <= 2) {
|
|
12798
13057
|
* yield* Console.log(`Attempt ${attempt} failed`)
|
|
12799
|
-
* yield* Effect.fail(`Error ${attempt}`)
|
|
13058
|
+
* return yield* Effect.fail(`Error ${attempt}`)
|
|
12800
13059
|
* }
|
|
12801
13060
|
* yield* Console.log(`Attempt ${attempt} succeeded`)
|
|
12802
13061
|
* return "success"
|
|
@@ -14195,7 +14454,7 @@ export declare const withParentSpan: {
|
|
|
14195
14454
|
* )
|
|
14196
14455
|
*
|
|
14197
14456
|
* const program = Effect.gen(function*() {
|
|
14198
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
14457
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
14199
14458
|
* yield* Console.log(name)
|
|
14200
14459
|
* })
|
|
14201
14460
|
* ```
|
|
@@ -14226,7 +14485,7 @@ export declare const request: {
|
|
|
14226
14485
|
* )
|
|
14227
14486
|
*
|
|
14228
14487
|
* const program = Effect.gen(function*() {
|
|
14229
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
14488
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
14230
14489
|
* yield* Console.log(name)
|
|
14231
14490
|
* })
|
|
14232
14491
|
* ```
|
|
@@ -14257,7 +14516,7 @@ export declare const request: {
|
|
|
14257
14516
|
* )
|
|
14258
14517
|
*
|
|
14259
14518
|
* const program = Effect.gen(function*() {
|
|
14260
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
14519
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
14261
14520
|
* yield* Console.log(name)
|
|
14262
14521
|
* })
|
|
14263
14522
|
* ```
|
|
@@ -14466,7 +14725,7 @@ export declare const forkScoped: <Arg extends Effect<any, any, any> | {
|
|
|
14466
14725
|
}>(effectOrOptions?: Arg, options?: {
|
|
14467
14726
|
readonly startImmediately?: boolean | undefined;
|
|
14468
14727
|
readonly uninterruptible?: boolean | "inherit" | undefined;
|
|
14469
|
-
} | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<Fiber<_A, _E>, never, _R> : <A, E, R>(self: Effect<A, E, R>) => Effect<Fiber<A, E>, never, R | Scope>;
|
|
14728
|
+
} | undefined) => [Arg] extends [Effect<infer _A, infer _E, infer _R>] ? Effect<Fiber<_A, _E>, never, _R | Scope> : <A, E, R>(self: Effect<A, E, R>) => Effect<Fiber<A, E>, never, R | Scope>;
|
|
14470
14729
|
/**
|
|
14471
14730
|
* Forks the effect into a new fiber attached to the global scope. Because the
|
|
14472
14731
|
* new fiber is attached to the global scope, when the fiber executing the
|
|
@@ -15772,7 +16031,7 @@ export declare const clockWith: <A, E, R>(f: (clock: Clock) => Effect<A, E, R>)
|
|
|
15772
16031
|
* @since 2.0.0
|
|
15773
16032
|
* @category Logging
|
|
15774
16033
|
*/
|
|
15775
|
-
export declare const logWithLevel: (level?:
|
|
16034
|
+
export declare const logWithLevel: (level?: Severity) => (...message: ReadonlyArray<any>) => Effect<void>;
|
|
15776
16035
|
/**
|
|
15777
16036
|
* Logs one or more messages using the default log level.
|
|
15778
16037
|
*
|
|
@@ -16039,6 +16298,85 @@ export declare const annotateLogs: {
|
|
|
16039
16298
|
<A, E, R>(effect: Effect<A, E, R>, key: string, value: unknown): Effect<A, E, R>;
|
|
16040
16299
|
<A, E, R>(effect: Effect<A, E, R>, values: Record<string, unknown>): Effect<A, E, R>;
|
|
16041
16300
|
};
|
|
16301
|
+
/**
|
|
16302
|
+
* Adds log annotations to the current scope.
|
|
16303
|
+
*
|
|
16304
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
16305
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
16306
|
+
* restores the previous annotations when the scope closes.
|
|
16307
|
+
*
|
|
16308
|
+
* @example
|
|
16309
|
+
* ```ts
|
|
16310
|
+
* import { Effect } from "effect"
|
|
16311
|
+
*
|
|
16312
|
+
* const program = Effect.scoped(
|
|
16313
|
+
* Effect.gen(function*() {
|
|
16314
|
+
* yield* Effect.log("before")
|
|
16315
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
16316
|
+
* yield* Effect.log("inside scope")
|
|
16317
|
+
* })
|
|
16318
|
+
* )
|
|
16319
|
+
*
|
|
16320
|
+
* Effect.runPromise(program)
|
|
16321
|
+
* ```
|
|
16322
|
+
*
|
|
16323
|
+
* @since 4.0.0
|
|
16324
|
+
* @category Logging
|
|
16325
|
+
*/
|
|
16326
|
+
export declare const annotateLogsScoped: {
|
|
16327
|
+
/**
|
|
16328
|
+
* Adds log annotations to the current scope.
|
|
16329
|
+
*
|
|
16330
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
16331
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
16332
|
+
* restores the previous annotations when the scope closes.
|
|
16333
|
+
*
|
|
16334
|
+
* @example
|
|
16335
|
+
* ```ts
|
|
16336
|
+
* import { Effect } from "effect"
|
|
16337
|
+
*
|
|
16338
|
+
* const program = Effect.scoped(
|
|
16339
|
+
* Effect.gen(function*() {
|
|
16340
|
+
* yield* Effect.log("before")
|
|
16341
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
16342
|
+
* yield* Effect.log("inside scope")
|
|
16343
|
+
* })
|
|
16344
|
+
* )
|
|
16345
|
+
*
|
|
16346
|
+
* Effect.runPromise(program)
|
|
16347
|
+
* ```
|
|
16348
|
+
*
|
|
16349
|
+
* @since 4.0.0
|
|
16350
|
+
* @category Logging
|
|
16351
|
+
*/
|
|
16352
|
+
(key: string, value: unknown): Effect<void, never, Scope>;
|
|
16353
|
+
/**
|
|
16354
|
+
* Adds log annotations to the current scope.
|
|
16355
|
+
*
|
|
16356
|
+
* This differs from `annotateLogs`, which only annotates a specific effect.
|
|
16357
|
+
* `annotateLogsScoped` updates annotations for the entire current `Scope` and
|
|
16358
|
+
* restores the previous annotations when the scope closes.
|
|
16359
|
+
*
|
|
16360
|
+
* @example
|
|
16361
|
+
* ```ts
|
|
16362
|
+
* import { Effect } from "effect"
|
|
16363
|
+
*
|
|
16364
|
+
* const program = Effect.scoped(
|
|
16365
|
+
* Effect.gen(function*() {
|
|
16366
|
+
* yield* Effect.log("before")
|
|
16367
|
+
* yield* Effect.annotateLogsScoped({ requestId: "req-123" })
|
|
16368
|
+
* yield* Effect.log("inside scope")
|
|
16369
|
+
* })
|
|
16370
|
+
* )
|
|
16371
|
+
*
|
|
16372
|
+
* Effect.runPromise(program)
|
|
16373
|
+
* ```
|
|
16374
|
+
*
|
|
16375
|
+
* @since 4.0.0
|
|
16376
|
+
* @category Logging
|
|
16377
|
+
*/
|
|
16378
|
+
(values: Record<string, unknown>): Effect<void, never, Scope>;
|
|
16379
|
+
};
|
|
16042
16380
|
/**
|
|
16043
16381
|
* Adds a span to each log line in this effect.
|
|
16044
16382
|
*
|
|
@@ -16574,18 +16912,20 @@ export declare const trackSuccesses: {
|
|
|
16574
16912
|
*
|
|
16575
16913
|
* @example
|
|
16576
16914
|
* ```ts
|
|
16577
|
-
* import { Effect, Metric } from "effect"
|
|
16915
|
+
* import { Data, Effect, Metric } from "effect"
|
|
16916
|
+
*
|
|
16917
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16578
16918
|
*
|
|
16579
16919
|
* // Track error types using frequency metric
|
|
16580
16920
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16581
16921
|
*
|
|
16582
|
-
* const program = Effect.fail(new
|
|
16583
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
16922
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
16923
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16584
16924
|
* )
|
|
16585
16925
|
*
|
|
16586
16926
|
* Effect.runPromiseExit(program).then(() =>
|
|
16587
16927
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16588
|
-
* // Output: { occurrences: Map(1) { "
|
|
16928
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16589
16929
|
* )
|
|
16590
16930
|
* ```
|
|
16591
16931
|
*
|
|
@@ -16620,18 +16960,20 @@ export declare const trackErrors: {
|
|
|
16620
16960
|
*
|
|
16621
16961
|
* @example
|
|
16622
16962
|
* ```ts
|
|
16623
|
-
* import { Effect, Metric } from "effect"
|
|
16963
|
+
* import { Data, Effect, Metric } from "effect"
|
|
16964
|
+
*
|
|
16965
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16624
16966
|
*
|
|
16625
16967
|
* // Track error types using frequency metric
|
|
16626
16968
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16627
16969
|
*
|
|
16628
|
-
* const program = Effect.fail(new
|
|
16629
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
16970
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
16971
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16630
16972
|
* )
|
|
16631
16973
|
*
|
|
16632
16974
|
* Effect.runPromiseExit(program).then(() =>
|
|
16633
16975
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16634
|
-
* // Output: { occurrences: Map(1) { "
|
|
16976
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16635
16977
|
* )
|
|
16636
16978
|
* ```
|
|
16637
16979
|
*
|
|
@@ -16666,18 +17008,20 @@ export declare const trackErrors: {
|
|
|
16666
17008
|
*
|
|
16667
17009
|
* @example
|
|
16668
17010
|
* ```ts
|
|
16669
|
-
* import { Effect, Metric } from "effect"
|
|
17011
|
+
* import { Data, Effect, Metric } from "effect"
|
|
17012
|
+
*
|
|
17013
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16670
17014
|
*
|
|
16671
17015
|
* // Track error types using frequency metric
|
|
16672
17016
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16673
17017
|
*
|
|
16674
|
-
* const program = Effect.fail(new
|
|
16675
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17018
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17019
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16676
17020
|
* )
|
|
16677
17021
|
*
|
|
16678
17022
|
* Effect.runPromiseExit(program).then(() =>
|
|
16679
17023
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16680
|
-
* // Output: { occurrences: Map(1) { "
|
|
17024
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16681
17025
|
* )
|
|
16682
17026
|
* ```
|
|
16683
17027
|
*
|
|
@@ -16712,18 +17056,20 @@ export declare const trackErrors: {
|
|
|
16712
17056
|
*
|
|
16713
17057
|
* @example
|
|
16714
17058
|
* ```ts
|
|
16715
|
-
* import { Effect, Metric } from "effect"
|
|
17059
|
+
* import { Data, Effect, Metric } from "effect"
|
|
17060
|
+
*
|
|
17061
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16716
17062
|
*
|
|
16717
17063
|
* // Track error types using frequency metric
|
|
16718
17064
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16719
17065
|
*
|
|
16720
|
-
* const program = Effect.fail(new
|
|
16721
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17066
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17067
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16722
17068
|
* )
|
|
16723
17069
|
*
|
|
16724
17070
|
* Effect.runPromiseExit(program).then(() =>
|
|
16725
17071
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16726
|
-
* // Output: { occurrences: Map(1) { "
|
|
17072
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16727
17073
|
* )
|
|
16728
17074
|
* ```
|
|
16729
17075
|
*
|
|
@@ -16758,18 +17104,20 @@ export declare const trackErrors: {
|
|
|
16758
17104
|
*
|
|
16759
17105
|
* @example
|
|
16760
17106
|
* ```ts
|
|
16761
|
-
* import { Effect, Metric } from "effect"
|
|
17107
|
+
* import { Data, Effect, Metric } from "effect"
|
|
17108
|
+
*
|
|
17109
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16762
17110
|
*
|
|
16763
17111
|
* // Track error types using frequency metric
|
|
16764
17112
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16765
17113
|
*
|
|
16766
|
-
* const program = Effect.fail(new
|
|
16767
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17114
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17115
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16768
17116
|
* )
|
|
16769
17117
|
*
|
|
16770
17118
|
* Effect.runPromiseExit(program).then(() =>
|
|
16771
17119
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16772
|
-
* // Output: { occurrences: Map(1) { "
|
|
17120
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16773
17121
|
* )
|
|
16774
17122
|
* ```
|
|
16775
17123
|
*
|
|
@@ -17281,118 +17629,63 @@ declare const Transaction_base: ServiceMap.ServiceClass<Transaction, "effect/Eff
|
|
|
17281
17629
|
export declare class Transaction extends Transaction_base {
|
|
17282
17630
|
}
|
|
17283
17631
|
/**
|
|
17284
|
-
*
|
|
17285
|
-
* transactional values (i.e. TxRef) that occur within the transaction body.
|
|
17286
|
-
*
|
|
17287
|
-
* In Effect transactions are optimistic with retry, that means transactions are retried when:
|
|
17288
|
-
*
|
|
17289
|
-
* - the body of the transaction explicitely calls to `Effect.retryTransaction` and any of the
|
|
17290
|
-
* accessed transactional values changes.
|
|
17291
|
-
*
|
|
17292
|
-
* - any of the accessed transactional values change during the execution of the transaction
|
|
17293
|
-
* due to a different transaction committing before the current.
|
|
17632
|
+
* Accesses the current transaction state within an active transaction.
|
|
17294
17633
|
*
|
|
17295
|
-
*
|
|
17296
|
-
*
|
|
17634
|
+
* This function requires `Transaction` in the context and does NOT create or strip
|
|
17635
|
+
* transaction boundaries. Use it to interact with the transaction journal (e.g. in
|
|
17636
|
+
* `TxRef` internals). To define a transaction boundary, use {@link transaction}.
|
|
17297
17637
|
*
|
|
17298
17638
|
* @example
|
|
17299
17639
|
* ```ts
|
|
17300
17640
|
* import { Effect, TxRef } from "effect"
|
|
17301
17641
|
*
|
|
17302
17642
|
* const program = Effect.gen(function*() {
|
|
17303
|
-
* const
|
|
17304
|
-
* const ref2 = yield* TxRef.make(0)
|
|
17305
|
-
*
|
|
17306
|
-
* // All operations within atomic block succeed or fail together
|
|
17307
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
17308
|
-
* yield* TxRef.set(ref1, 10)
|
|
17309
|
-
* yield* TxRef.set(ref2, 20)
|
|
17310
|
-
* const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
|
|
17311
|
-
* console.log(`Transaction sum: ${sum}`)
|
|
17312
|
-
* }))
|
|
17313
|
-
*
|
|
17314
|
-
* console.log(`Final ref1: ${yield* TxRef.get(ref1)}`) // 10
|
|
17315
|
-
* console.log(`Final ref2: ${yield* TxRef.get(ref2)}`) // 20
|
|
17316
|
-
* })
|
|
17317
|
-
* ```
|
|
17318
|
-
*
|
|
17319
|
-
* @since 4.0.0
|
|
17320
|
-
* @category Transactions
|
|
17321
|
-
*/
|
|
17322
|
-
export declare const atomic: <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, Exclude<R, Transaction>>;
|
|
17323
|
-
/**
|
|
17324
|
-
* Executes a function within a transaction context, providing access to the transaction state.
|
|
17325
|
-
*
|
|
17326
|
-
* @example
|
|
17327
|
-
* ```ts
|
|
17328
|
-
* import { Effect, TxRef } from "effect"
|
|
17329
|
-
*
|
|
17330
|
-
* const program = Effect.atomicWith((txState) =>
|
|
17331
|
-
* Effect.gen(function*() {
|
|
17332
|
-
* const ref = yield* TxRef.make(0)
|
|
17333
|
-
*
|
|
17334
|
-
* // Access transaction state for debugging
|
|
17335
|
-
* console.log(`Journal size: ${txState.journal.size}`)
|
|
17336
|
-
* console.log(`Retry flag: ${txState.retry}`)
|
|
17643
|
+
* const ref = yield* Effect.transaction(TxRef.make(0))
|
|
17337
17644
|
*
|
|
17645
|
+
* yield* Effect.transaction(Effect.gen(function*() {
|
|
17338
17646
|
* yield* TxRef.set(ref, 42)
|
|
17339
17647
|
* return yield* TxRef.get(ref)
|
|
17340
|
-
* })
|
|
17341
|
-
* )
|
|
17342
|
-
*
|
|
17343
|
-
* Effect.runPromise(program).then(console.log) // 42
|
|
17648
|
+
* }))
|
|
17649
|
+
* })
|
|
17344
17650
|
* ```
|
|
17345
17651
|
*
|
|
17346
17652
|
* @since 4.0.0
|
|
17347
17653
|
* @category Transactions
|
|
17348
17654
|
*/
|
|
17349
|
-
export declare const
|
|
17655
|
+
export declare const withTxState: <A, E, R>(f: (state: Transaction["Service"]) => Effect<A, E, R>) => Effect<A, E, R | Transaction>;
|
|
17350
17656
|
/**
|
|
17351
|
-
*
|
|
17657
|
+
* Defines a transaction boundary. Transactions are "all or nothing" with respect to changes
|
|
17658
|
+
* made to transactional values (i.e. TxRef) that occur within the transaction body.
|
|
17352
17659
|
*
|
|
17353
|
-
*
|
|
17660
|
+
* In Effect transactions are optimistic with retry, that means transactions are retried when:
|
|
17354
17661
|
*
|
|
17355
|
-
*
|
|
17356
|
-
*
|
|
17357
|
-
* This ensures complete isolation between different transaction scopes.
|
|
17662
|
+
* - the body of the transaction explicitely calls to `Effect.retryTransaction` and any of the
|
|
17663
|
+
* accessed transactional values changes.
|
|
17358
17664
|
*
|
|
17359
|
-
*
|
|
17360
|
-
*
|
|
17361
|
-
* - Parent transaction failures don't affect isolated transactions
|
|
17362
|
-
* - Isolated transaction failures don't affect parent transactions
|
|
17363
|
-
* - Each transaction has its own journal and retry logic
|
|
17665
|
+
* - any of the accessed transactional values change during the execution of the transaction
|
|
17666
|
+
* due to a different transaction committing before the current.
|
|
17364
17667
|
*
|
|
17365
|
-
*
|
|
17366
|
-
*
|
|
17367
|
-
* - For implementing independent operations that shouldn't be affected by outer transactions
|
|
17368
|
-
* - When building transaction-based systems where isolation is critical
|
|
17668
|
+
* Each call to `transaction` always creates a new isolated transaction boundary with its own
|
|
17669
|
+
* journal and retry logic.
|
|
17369
17670
|
*
|
|
17370
17671
|
* @example
|
|
17371
17672
|
* ```ts
|
|
17372
17673
|
* import { Effect, TxRef } from "effect"
|
|
17373
17674
|
*
|
|
17374
17675
|
* const program = Effect.gen(function*() {
|
|
17375
|
-
* const ref1 = yield* TxRef.make(0)
|
|
17376
|
-
* const ref2 = yield* TxRef.make(
|
|
17377
|
-
*
|
|
17378
|
-
* // Nested atomic transaction - ref1 will be part of outer transaction
|
|
17379
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
17380
|
-
* yield* TxRef.set(ref1, 10)
|
|
17676
|
+
* const ref1 = yield* Effect.transaction(TxRef.make(0))
|
|
17677
|
+
* const ref2 = yield* Effect.transaction(TxRef.make(0))
|
|
17381
17678
|
*
|
|
17382
|
-
*
|
|
17383
|
-
* yield* Effect.atomic(Effect.gen(function*() {
|
|
17384
|
-
* yield* TxRef.set(ref1, 20) // Part of same transaction
|
|
17385
|
-
* }))
|
|
17386
|
-
* }))
|
|
17387
|
-
*
|
|
17388
|
-
* // Isolated transaction - ref2 will be in its own transaction
|
|
17679
|
+
* // All operations within transaction block succeed or fail together
|
|
17389
17680
|
* yield* Effect.transaction(Effect.gen(function*() {
|
|
17390
|
-
* yield* TxRef.set(
|
|
17681
|
+
* yield* TxRef.set(ref1, 10)
|
|
17682
|
+
* yield* TxRef.set(ref2, 20)
|
|
17683
|
+
* const sum = (yield* TxRef.get(ref1)) + (yield* TxRef.get(ref2))
|
|
17684
|
+
* console.log(`Transaction sum: ${sum}`)
|
|
17391
17685
|
* }))
|
|
17392
17686
|
*
|
|
17393
|
-
*
|
|
17394
|
-
*
|
|
17395
|
-
* return { ref1: val1, ref2: val2 }
|
|
17687
|
+
* console.log(`Final ref1: ${yield* Effect.transaction(TxRef.get(ref1))}`) // 10
|
|
17688
|
+
* console.log(`Final ref2: ${yield* Effect.transaction(TxRef.get(ref2))}`) // 20
|
|
17396
17689
|
* })
|
|
17397
17690
|
* ```
|
|
17398
17691
|
*
|
|
@@ -17401,34 +17694,21 @@ export declare const atomicWith: <A, E, R>(f: (state: Transaction["Service"]) =>
|
|
|
17401
17694
|
*/
|
|
17402
17695
|
export declare const transaction: <A, E, R>(effect: Effect<A, E, R>) => Effect<A, E, Exclude<R, Transaction>>;
|
|
17403
17696
|
/**
|
|
17404
|
-
*
|
|
17697
|
+
* Like {@link transaction} but provides access to the transaction state.
|
|
17405
17698
|
*
|
|
17406
|
-
*
|
|
17407
|
-
* within another transaction. This ensures complete isolation between transaction scopes.
|
|
17699
|
+
* Always creates a new isolated transaction boundary with its own journal and retry logic.
|
|
17408
17700
|
*
|
|
17409
17701
|
* @example
|
|
17410
17702
|
* ```ts
|
|
17411
17703
|
* import { Effect, TxRef } from "effect"
|
|
17412
17704
|
*
|
|
17413
|
-
* const program = Effect.transactionWith((
|
|
17705
|
+
* const program = Effect.transactionWith((_txState) =>
|
|
17414
17706
|
* Effect.gen(function*() {
|
|
17415
17707
|
* const ref = yield* TxRef.make(0)
|
|
17416
|
-
*
|
|
17417
|
-
* // This transaction is isolated - it has its own journal
|
|
17418
|
-
* // txState.journal is independent of any parent transaction
|
|
17419
|
-
*
|
|
17420
17708
|
* yield* TxRef.set(ref, 42)
|
|
17421
17709
|
* return yield* TxRef.get(ref)
|
|
17422
17710
|
* })
|
|
17423
17711
|
* )
|
|
17424
|
-
*
|
|
17425
|
-
* // Even when nested in another atomic block, this transaction is isolated
|
|
17426
|
-
* const nestedProgram = Effect.atomic(
|
|
17427
|
-
* Effect.gen(function*() {
|
|
17428
|
-
* const result = yield* program // Runs in its own isolated transaction
|
|
17429
|
-
* return result
|
|
17430
|
-
* })
|
|
17431
|
-
* )
|
|
17432
17712
|
* ```
|
|
17433
17713
|
*
|
|
17434
17714
|
* @since 4.0.0
|
|
@@ -17450,16 +17730,16 @@ export declare const transactionWith: <A, E, R>(f: (state: Transaction["Service"
|
|
|
17450
17730
|
*
|
|
17451
17731
|
* const program = Effect.gen(function*() {
|
|
17452
17732
|
* // create a transactional reference
|
|
17453
|
-
* const ref = yield* TxRef.make(0)
|
|
17733
|
+
* const ref = yield* Effect.transaction(TxRef.make(0))
|
|
17454
17734
|
*
|
|
17455
17735
|
* // forks a fiber that increases the value of `ref` every 100 millis
|
|
17456
17736
|
* yield* Effect.forkChild(Effect.forever(
|
|
17457
17737
|
* // update to transactional value
|
|
17458
|
-
* TxRef.update(ref, (n) => n + 1).pipe(Effect.delay("100 millis"))
|
|
17738
|
+
* Effect.transaction(TxRef.update(ref, (n) => n + 1)).pipe(Effect.delay("100 millis"))
|
|
17459
17739
|
* ))
|
|
17460
17740
|
*
|
|
17461
17741
|
* // the following will retry 10 times until the `ref` value is 10
|
|
17462
|
-
* yield* Effect.
|
|
17742
|
+
* yield* Effect.transaction(Effect.gen(function*() {
|
|
17463
17743
|
* const value = yield* TxRef.get(ref)
|
|
17464
17744
|
* if (value < 10) {
|
|
17465
17745
|
* yield* Effect.log(`retry due to value: ${value}`)
|
|
@@ -17912,18 +18192,20 @@ export declare const satisfiesSuccessType: <A>() => <A2 extends A, E, R>(effect:
|
|
|
17912
18192
|
*
|
|
17913
18193
|
* @example
|
|
17914
18194
|
* ```ts
|
|
17915
|
-
* import { Effect } from "effect"
|
|
18195
|
+
* import { Data, Effect } from "effect"
|
|
18196
|
+
*
|
|
18197
|
+
* class ValidationError extends Data.TaggedError("ValidationError")<{}> {}
|
|
17916
18198
|
*
|
|
17917
|
-
* // Define a constraint that the error type must be
|
|
17918
|
-
* const satisfiesError = Effect.satisfiesErrorType<
|
|
18199
|
+
* // Define a constraint that the error type must be a ValidationError
|
|
18200
|
+
* const satisfiesError = Effect.satisfiesErrorType<ValidationError>()
|
|
17919
18201
|
*
|
|
17920
|
-
* // This works - Effect<number,
|
|
17921
|
-
* const validEffect = satisfiesError(Effect.fail(new
|
|
18202
|
+
* // This works - Effect<number, ValidationError, never> extends the constrained type
|
|
18203
|
+
* const validEffect = satisfiesError(Effect.fail(new ValidationError()))
|
|
17922
18204
|
*
|
|
17923
18205
|
* // This would cause a TypeScript compilation error:
|
|
17924
18206
|
* // const invalidEffect = satisfiesError(Effect.fail("string error"))
|
|
17925
18207
|
* // ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
17926
|
-
* // Type 'string' is not assignable to type '
|
|
18208
|
+
* // Type 'string' is not assignable to type 'ValidationError'
|
|
17927
18209
|
* ```
|
|
17928
18210
|
*
|
|
17929
18211
|
* @since 4.0.0
|