effect 4.0.0-beta.27 → 4.0.0-beta.29
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/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/ConfigProvider.d.ts +1 -1
- package/dist/Cron.d.ts +1 -1
- package/dist/Data.d.ts +1 -1
- package/dist/Data.d.ts.map +1 -1
- package/dist/Data.js.map +1 -1
- package/dist/Effect.d.ts +300 -184
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +99 -61
- package/dist/Effect.js.map +1 -1
- package/dist/Encoding.d.ts +1 -1
- 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 +1 -0
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.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/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/PlatformError.d.ts +2 -2
- package/dist/References.d.ts +6 -1
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +6 -1
- package/dist/References.js.map +1 -1
- package/dist/RequestResolver.d.ts +19 -19
- package/dist/RequestResolver.js +10 -10
- package/dist/RequestResolver.js.map +1 -1
- package/dist/Schedule.d.ts +142 -80
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +58 -32
- 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 +1 -1
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +3 -1
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +1 -1
- package/dist/SchemaAST.js.map +1 -1
- package/dist/Stdio.d.ts +6 -2
- package/dist/Stdio.d.ts.map +1 -1
- package/dist/Stdio.js +2 -2
- package/dist/Stdio.js.map +1 -1
- package/dist/Stream.d.ts +8 -4
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +8 -4
- package/dist/Stream.js.map +1 -1
- package/dist/Types.d.ts +1 -22
- package/dist/Types.d.ts.map +1 -1
- package/dist/index.d.ts +71 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +71 -3
- package/dist/index.js.map +1 -1
- package/dist/internal/effect.js +3 -1
- package/dist/internal/effect.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts +12 -28
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +4 -18
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +20 -1
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +8 -0
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts +65 -12
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +159 -45
- package/dist/unstable/ai/McpServer.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/internal/codec-transformer.js +0 -5
- package/dist/unstable/ai/internal/codec-transformer.js.map +1 -1
- package/dist/unstable/cli/Prompt.js +35 -8
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/cluster/Message.d.ts +5 -5
- package/dist/unstable/cluster/Reply.d.ts +3 -3
- 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 +1 -1
- package/dist/unstable/eventlog/EventJournal.d.ts +1 -1
- package/dist/unstable/eventlog/EventLogRemote.d.ts +1 -1
- package/dist/unstable/http/Cookies.d.ts +45 -1
- package/dist/unstable/http/Cookies.d.ts.map +1 -1
- package/dist/unstable/http/Cookies.js +22 -0
- package/dist/unstable/http/Cookies.js.map +1 -1
- package/dist/unstable/http/HttpBody.d.ts +1 -1
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js +3 -7
- 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 +5 -0
- package/dist/unstable/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/unstable/http/HttpClientRequest.js +21 -17
- package/dist/unstable/http/HttpClientRequest.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +7 -0
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +6 -0
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +6 -6
- package/dist/unstable/http/HttpServerRequest.d.ts +11 -0
- 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/HttpServerResponse.d.ts +47 -1
- package/dist/unstable/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerResponse.js +227 -0
- 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 +1 -1
- package/dist/unstable/http/UrlParams.d.ts +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/httpapi/HttpApiGroup.d.ts +1 -0
- package/dist/unstable/httpapi/HttpApiGroup.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiGroup.js.map +1 -1
- package/dist/unstable/persistence/KeyValueStore.d.ts +1 -1
- package/dist/unstable/reactivity/Atom.d.ts +7 -2
- package/dist/unstable/reactivity/Atom.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +33 -15
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +4 -6
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +39 -9
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomRegistry.js +26 -2
- package/dist/unstable/reactivity/AtomRegistry.js.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.d.ts +8 -8
- package/dist/unstable/reactivity/AtomRpc.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomRpc.js +46 -20
- package/dist/unstable/reactivity/AtomRpc.js.map +1 -1
- package/dist/unstable/rpc/Rpc.d.ts +1 -1
- package/dist/unstable/rpc/Rpc.d.ts.map +1 -1
- package/dist/unstable/rpc/Rpc.js.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.d.ts +5 -5
- package/dist/unstable/rpc/RpcMiddleware.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcMiddleware.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +2 -2
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/dist/unstable/rpc/Utils.js +1 -1
- package/dist/unstable/rpc/Utils.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/SqlResolver.js +2 -2
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +1 -1
- package/package.json +1 -1
- package/src/Brand.ts +1 -1
- package/src/Data.ts +1 -2
- package/src/Effect.ts +300 -184
- package/src/Exit.ts +24 -12
- package/src/Fiber.ts +1 -0
- package/src/Function.ts +2 -10
- package/src/Newtype.ts +308 -0
- package/src/References.ts +6 -1
- package/src/RequestResolver.ts +20 -20
- package/src/Schedule.ts +142 -80
- package/src/Scheduler.ts +12 -0
- package/src/Schema.ts +4 -2
- package/src/SchemaAST.ts +1 -4
- package/src/Stdio.ts +8 -4
- package/src/Stream.ts +8 -4
- package/src/Types.ts +1 -23
- package/src/index.ts +72 -3
- package/src/internal/effect.ts +3 -0
- package/src/unstable/ai/LanguageModel.ts +16 -37
- package/src/unstable/ai/McpSchema.ts +14 -0
- package/src/unstable/ai/McpServer.ts +224 -53
- package/src/unstable/ai/Toolkit.ts +5 -14
- package/src/unstable/ai/internal/codec-transformer.ts +0 -7
- package/src/unstable/cli/Prompt.ts +31 -9
- package/src/unstable/http/Cookies.ts +84 -0
- package/src/unstable/http/HttpClient.ts +5 -6
- package/src/unstable/http/HttpClientRequest.ts +21 -17
- package/src/unstable/http/HttpEffect.ts +8 -0
- package/src/unstable/http/HttpServerRequest.ts +388 -1
- package/src/unstable/http/HttpServerResponse.ts +328 -1
- package/src/unstable/http/HttpStaticServer.ts +456 -0
- package/src/unstable/http/index.ts +5 -0
- package/src/unstable/httpapi/HttpApiGroup.ts +1 -0
- package/src/unstable/reactivity/Atom.ts +62 -35
- package/src/unstable/reactivity/AtomHttpApi.ts +45 -11
- package/src/unstable/reactivity/AtomRegistry.ts +30 -2
- package/src/unstable/reactivity/AtomRpc.ts +48 -17
- package/src/unstable/rpc/Rpc.ts +1 -3
- package/src/unstable/rpc/RpcMiddleware.ts +12 -6
- package/src/unstable/rpc/RpcServer.ts +2 -2
- package/src/unstable/rpc/Utils.ts +1 -1
- package/src/unstable/sql/SqlResolver.ts +2 -2
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
|
|
@@ -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
|
*/
|
|
@@ -1352,16 +1358,18 @@ export declare const promise: <A>(evaluate: (signal: AbortSignal) => PromiseLike
|
|
|
1352
1358
|
*
|
|
1353
1359
|
* @example Custom Error Handling
|
|
1354
1360
|
* ```ts
|
|
1355
|
-
* import { Effect } from "effect"
|
|
1361
|
+
* import { Data, Effect } from "effect"
|
|
1362
|
+
*
|
|
1363
|
+
* class TodoFetchError extends Data.TaggedError("TodoFetchError")<{ readonly cause: unknown }> {}
|
|
1356
1364
|
*
|
|
1357
1365
|
* const getTodo = (id: number) =>
|
|
1358
1366
|
* Effect.tryPromise({
|
|
1359
1367
|
* try: () => fetch(`https://jsonplaceholder.typicode.com/todos/${id}`),
|
|
1360
1368
|
* // remap the error
|
|
1361
|
-
* catch: (
|
|
1369
|
+
* catch: (cause) => new TodoFetchError({ cause })
|
|
1362
1370
|
* })
|
|
1363
1371
|
*
|
|
1364
|
-
* // ┌─── Effect<Response,
|
|
1372
|
+
* // ┌─── Effect<Response, TodoFetchError, never>
|
|
1365
1373
|
* // ▼
|
|
1366
1374
|
* const program = getTodo(1)
|
|
1367
1375
|
* ```
|
|
@@ -1737,16 +1745,18 @@ export declare const bind: {
|
|
|
1737
1745
|
*
|
|
1738
1746
|
* @example
|
|
1739
1747
|
* ```ts
|
|
1740
|
-
* import { Effect } from "effect"
|
|
1748
|
+
* import { Data, Effect } from "effect"
|
|
1749
|
+
*
|
|
1750
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1741
1751
|
*
|
|
1742
1752
|
* const addServiceCharge = (amount: number) => amount + 1
|
|
1743
1753
|
*
|
|
1744
1754
|
* const applyDiscount = (
|
|
1745
1755
|
* total: number,
|
|
1746
1756
|
* discountRate: number
|
|
1747
|
-
* ): Effect.Effect<number,
|
|
1757
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1748
1758
|
* discountRate === 0
|
|
1749
|
-
* ? Effect.fail(new
|
|
1759
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1750
1760
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1751
1761
|
*
|
|
1752
1762
|
* const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
|
|
@@ -1786,16 +1796,18 @@ export declare const gen: {
|
|
|
1786
1796
|
*
|
|
1787
1797
|
* @example
|
|
1788
1798
|
* ```ts
|
|
1789
|
-
* import { Effect } from "effect"
|
|
1799
|
+
* import { Data, Effect } from "effect"
|
|
1800
|
+
*
|
|
1801
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1790
1802
|
*
|
|
1791
1803
|
* const addServiceCharge = (amount: number) => amount + 1
|
|
1792
1804
|
*
|
|
1793
1805
|
* const applyDiscount = (
|
|
1794
1806
|
* total: number,
|
|
1795
1807
|
* discountRate: number
|
|
1796
|
-
* ): Effect.Effect<number,
|
|
1808
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1797
1809
|
* discountRate === 0
|
|
1798
|
-
* ? Effect.fail(new
|
|
1810
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1799
1811
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1800
1812
|
*
|
|
1801
1813
|
* const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
|
|
@@ -1839,16 +1851,18 @@ export declare const gen: {
|
|
|
1839
1851
|
*
|
|
1840
1852
|
* @example
|
|
1841
1853
|
* ```ts
|
|
1842
|
-
* import { Effect } from "effect"
|
|
1854
|
+
* import { Data, Effect } from "effect"
|
|
1855
|
+
*
|
|
1856
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
1843
1857
|
*
|
|
1844
1858
|
* const addServiceCharge = (amount: number) => amount + 1
|
|
1845
1859
|
*
|
|
1846
1860
|
* const applyDiscount = (
|
|
1847
1861
|
* total: number,
|
|
1848
1862
|
* discountRate: number
|
|
1849
|
-
* ): Effect.Effect<number,
|
|
1863
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
1850
1864
|
* discountRate === 0
|
|
1851
|
-
* ? Effect.fail(new
|
|
1865
|
+
* ? Effect.fail(new DiscountRateError())
|
|
1852
1866
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
1853
1867
|
*
|
|
1854
1868
|
* const fetchTransactionAmount = Effect.promise(() => Promise.resolve(100))
|
|
@@ -1903,12 +1917,14 @@ export declare namespace gen {
|
|
|
1903
1917
|
* @example
|
|
1904
1918
|
* ```ts
|
|
1905
1919
|
* // Title: Creating a Failed Effect
|
|
1906
|
-
* import { Effect } from "effect"
|
|
1920
|
+
* import { Data, Effect } from "effect"
|
|
1907
1921
|
*
|
|
1908
|
-
*
|
|
1922
|
+
* class OperationFailedError extends Data.TaggedError("OperationFailedError")<{}> {}
|
|
1923
|
+
*
|
|
1924
|
+
* // ┌─── Effect<never, OperationFailedError, never>
|
|
1909
1925
|
* // ▼
|
|
1910
1926
|
* const failure = Effect.fail(
|
|
1911
|
-
* new
|
|
1927
|
+
* new OperationFailedError()
|
|
1912
1928
|
* )
|
|
1913
1929
|
* ```
|
|
1914
1930
|
*
|
|
@@ -1924,9 +1940,11 @@ export declare const fail: <E>(error: E) => Effect<never, E>;
|
|
|
1924
1940
|
*
|
|
1925
1941
|
* @example
|
|
1926
1942
|
* ```ts
|
|
1927
|
-
* import { Effect } from "effect"
|
|
1943
|
+
* import { Data, Effect } from "effect"
|
|
1944
|
+
*
|
|
1945
|
+
* class ProgramError extends Data.TaggedError("ProgramError")<{ readonly failedAt: Date }> {}
|
|
1928
1946
|
*
|
|
1929
|
-
* const program = Effect.failSync(() => new
|
|
1947
|
+
* const program = Effect.failSync(() => new ProgramError({ failedAt: new Date() }))
|
|
1930
1948
|
*
|
|
1931
1949
|
* Effect.runPromiseExit(program).then(console.log)
|
|
1932
1950
|
* // Output: { _id: 'Exit', _tag: 'Failure', cause: ... }
|
|
@@ -2073,12 +2091,14 @@ export {
|
|
|
2073
2091
|
*
|
|
2074
2092
|
* @example Custom Error Handling
|
|
2075
2093
|
* ```ts
|
|
2076
|
-
* import { Effect } from "effect"
|
|
2094
|
+
* import { Data, Effect } from "effect"
|
|
2095
|
+
*
|
|
2096
|
+
* class JsonParsingError extends Data.TaggedError("JsonParsingError")<{ readonly cause: unknown }> {}
|
|
2077
2097
|
*
|
|
2078
2098
|
* const parseJSON = (input: string) =>
|
|
2079
2099
|
* Effect.try({
|
|
2080
2100
|
* try: () => JSON.parse(input),
|
|
2081
|
-
* catch: (
|
|
2101
|
+
* catch: (cause) => new JsonParsingError({ cause })
|
|
2082
2102
|
* })
|
|
2083
2103
|
*
|
|
2084
2104
|
* Effect.runPromiseExit(parseJSON("invalid json")).then(console.log)
|
|
@@ -2271,15 +2291,17 @@ export declare const fromYieldable: <Self extends Yieldable.Any, A, E, R>(yielda
|
|
|
2271
2291
|
*
|
|
2272
2292
|
* @example
|
|
2273
2293
|
* ```ts
|
|
2274
|
-
* import { Effect, pipe } from "effect"
|
|
2294
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2295
|
+
*
|
|
2296
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2275
2297
|
*
|
|
2276
2298
|
* // Function to apply a discount safely to a transaction amount
|
|
2277
2299
|
* const applyDiscount = (
|
|
2278
2300
|
* total: number,
|
|
2279
2301
|
* discountRate: number
|
|
2280
|
-
* ): Effect.Effect<number,
|
|
2302
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2281
2303
|
* discountRate === 0
|
|
2282
|
-
* ? Effect.fail(new
|
|
2304
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2283
2305
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2284
2306
|
*
|
|
2285
2307
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2333,15 +2355,17 @@ export declare const flatMap: {
|
|
|
2333
2355
|
*
|
|
2334
2356
|
* @example
|
|
2335
2357
|
* ```ts
|
|
2336
|
-
* import { Effect, pipe } from "effect"
|
|
2358
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2359
|
+
*
|
|
2360
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2337
2361
|
*
|
|
2338
2362
|
* // Function to apply a discount safely to a transaction amount
|
|
2339
2363
|
* const applyDiscount = (
|
|
2340
2364
|
* total: number,
|
|
2341
2365
|
* discountRate: number
|
|
2342
|
-
* ): Effect.Effect<number,
|
|
2366
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2343
2367
|
* discountRate === 0
|
|
2344
|
-
* ? Effect.fail(new
|
|
2368
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2345
2369
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2346
2370
|
*
|
|
2347
2371
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2395,15 +2419,17 @@ export declare const flatMap: {
|
|
|
2395
2419
|
*
|
|
2396
2420
|
* @example
|
|
2397
2421
|
* ```ts
|
|
2398
|
-
* import { Effect, pipe } from "effect"
|
|
2422
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2423
|
+
*
|
|
2424
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2399
2425
|
*
|
|
2400
2426
|
* // Function to apply a discount safely to a transaction amount
|
|
2401
2427
|
* const applyDiscount = (
|
|
2402
2428
|
* total: number,
|
|
2403
2429
|
* discountRate: number
|
|
2404
|
-
* ): Effect.Effect<number,
|
|
2430
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2405
2431
|
* discountRate === 0
|
|
2406
|
-
* ? Effect.fail(new
|
|
2432
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2407
2433
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2408
2434
|
*
|
|
2409
2435
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2488,15 +2514,17 @@ export declare const flatten: <A, E, R, E2, R2>(self: Effect<Effect<A, E, R>, E2
|
|
|
2488
2514
|
*
|
|
2489
2515
|
* @example Applying a Discount Based on Fetched Amount
|
|
2490
2516
|
* ```ts
|
|
2491
|
-
* import { Effect, pipe } from "effect"
|
|
2517
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2518
|
+
*
|
|
2519
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2492
2520
|
*
|
|
2493
2521
|
* // Function to apply a discount safely to a transaction amount
|
|
2494
2522
|
* const applyDiscount = (
|
|
2495
2523
|
* total: number,
|
|
2496
2524
|
* discountRate: number
|
|
2497
|
-
* ): Effect.Effect<number,
|
|
2525
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2498
2526
|
* discountRate === 0
|
|
2499
|
-
* ? Effect.fail(new
|
|
2527
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2500
2528
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2501
2529
|
*
|
|
2502
2530
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2569,15 +2597,17 @@ export declare const andThen: {
|
|
|
2569
2597
|
*
|
|
2570
2598
|
* @example Applying a Discount Based on Fetched Amount
|
|
2571
2599
|
* ```ts
|
|
2572
|
-
* import { Effect, pipe } from "effect"
|
|
2600
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2601
|
+
*
|
|
2602
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2573
2603
|
*
|
|
2574
2604
|
* // Function to apply a discount safely to a transaction amount
|
|
2575
2605
|
* const applyDiscount = (
|
|
2576
2606
|
* total: number,
|
|
2577
2607
|
* discountRate: number
|
|
2578
|
-
* ): Effect.Effect<number,
|
|
2608
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2579
2609
|
* discountRate === 0
|
|
2580
|
-
* ? Effect.fail(new
|
|
2610
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2581
2611
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2582
2612
|
*
|
|
2583
2613
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2650,15 +2680,17 @@ export declare const andThen: {
|
|
|
2650
2680
|
*
|
|
2651
2681
|
* @example Applying a Discount Based on Fetched Amount
|
|
2652
2682
|
* ```ts
|
|
2653
|
-
* import { Effect, pipe } from "effect"
|
|
2683
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2684
|
+
*
|
|
2685
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2654
2686
|
*
|
|
2655
2687
|
* // Function to apply a discount safely to a transaction amount
|
|
2656
2688
|
* const applyDiscount = (
|
|
2657
2689
|
* total: number,
|
|
2658
2690
|
* discountRate: number
|
|
2659
|
-
* ): Effect.Effect<number,
|
|
2691
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2660
2692
|
* discountRate === 0
|
|
2661
|
-
* ? Effect.fail(new
|
|
2693
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2662
2694
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2663
2695
|
*
|
|
2664
2696
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2731,15 +2763,17 @@ export declare const andThen: {
|
|
|
2731
2763
|
*
|
|
2732
2764
|
* @example Applying a Discount Based on Fetched Amount
|
|
2733
2765
|
* ```ts
|
|
2734
|
-
* import { Effect, pipe } from "effect"
|
|
2766
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2767
|
+
*
|
|
2768
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2735
2769
|
*
|
|
2736
2770
|
* // Function to apply a discount safely to a transaction amount
|
|
2737
2771
|
* const applyDiscount = (
|
|
2738
2772
|
* total: number,
|
|
2739
2773
|
* discountRate: number
|
|
2740
|
-
* ): Effect.Effect<number,
|
|
2774
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2741
2775
|
* discountRate === 0
|
|
2742
|
-
* ? Effect.fail(new
|
|
2776
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2743
2777
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2744
2778
|
*
|
|
2745
2779
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2812,15 +2846,17 @@ export declare const andThen: {
|
|
|
2812
2846
|
*
|
|
2813
2847
|
* @example Applying a Discount Based on Fetched Amount
|
|
2814
2848
|
* ```ts
|
|
2815
|
-
* import { Effect, pipe } from "effect"
|
|
2849
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2850
|
+
*
|
|
2851
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2816
2852
|
*
|
|
2817
2853
|
* // Function to apply a discount safely to a transaction amount
|
|
2818
2854
|
* const applyDiscount = (
|
|
2819
2855
|
* total: number,
|
|
2820
2856
|
* discountRate: number
|
|
2821
|
-
* ): Effect.Effect<number,
|
|
2857
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2822
2858
|
* discountRate === 0
|
|
2823
|
-
* ? Effect.fail(new
|
|
2859
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2824
2860
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2825
2861
|
*
|
|
2826
2862
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2878,16 +2914,18 @@ export declare const andThen: {
|
|
|
2878
2914
|
* @example
|
|
2879
2915
|
* ```ts
|
|
2880
2916
|
* // Title: Logging a step in a pipeline
|
|
2881
|
-
* import { Effect, pipe } from "effect"
|
|
2917
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2882
2918
|
* import { Console } from "effect"
|
|
2883
2919
|
*
|
|
2920
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2921
|
+
*
|
|
2884
2922
|
* // Function to apply a discount safely to a transaction amount
|
|
2885
2923
|
* const applyDiscount = (
|
|
2886
2924
|
* total: number,
|
|
2887
2925
|
* discountRate: number
|
|
2888
|
-
* ): Effect.Effect<number,
|
|
2926
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2889
2927
|
* discountRate === 0
|
|
2890
|
-
* ? Effect.fail(new
|
|
2928
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2891
2929
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2892
2930
|
*
|
|
2893
2931
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2937,16 +2975,18 @@ export declare const tap: {
|
|
|
2937
2975
|
* @example
|
|
2938
2976
|
* ```ts
|
|
2939
2977
|
* // Title: Logging a step in a pipeline
|
|
2940
|
-
* import { Effect, pipe } from "effect"
|
|
2978
|
+
* import { Data, Effect, pipe } from "effect"
|
|
2941
2979
|
* import { Console } from "effect"
|
|
2942
2980
|
*
|
|
2981
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
2982
|
+
*
|
|
2943
2983
|
* // Function to apply a discount safely to a transaction amount
|
|
2944
2984
|
* const applyDiscount = (
|
|
2945
2985
|
* total: number,
|
|
2946
2986
|
* discountRate: number
|
|
2947
|
-
* ): Effect.Effect<number,
|
|
2987
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
2948
2988
|
* discountRate === 0
|
|
2949
|
-
* ? Effect.fail(new
|
|
2989
|
+
* ? Effect.fail(new DiscountRateError())
|
|
2950
2990
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
2951
2991
|
*
|
|
2952
2992
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -2996,16 +3036,18 @@ export declare const tap: {
|
|
|
2996
3036
|
* @example
|
|
2997
3037
|
* ```ts
|
|
2998
3038
|
* // Title: Logging a step in a pipeline
|
|
2999
|
-
* import { Effect, pipe } from "effect"
|
|
3039
|
+
* import { Data, Effect, pipe } from "effect"
|
|
3000
3040
|
* import { Console } from "effect"
|
|
3001
3041
|
*
|
|
3042
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3043
|
+
*
|
|
3002
3044
|
* // Function to apply a discount safely to a transaction amount
|
|
3003
3045
|
* const applyDiscount = (
|
|
3004
3046
|
* total: number,
|
|
3005
3047
|
* discountRate: number
|
|
3006
|
-
* ): Effect.Effect<number,
|
|
3048
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
3007
3049
|
* discountRate === 0
|
|
3008
|
-
* ? Effect.fail(new
|
|
3050
|
+
* ? Effect.fail(new DiscountRateError())
|
|
3009
3051
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
3010
3052
|
*
|
|
3011
3053
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -3055,16 +3097,18 @@ export declare const tap: {
|
|
|
3055
3097
|
* @example
|
|
3056
3098
|
* ```ts
|
|
3057
3099
|
* // Title: Logging a step in a pipeline
|
|
3058
|
-
* import { Effect, pipe } from "effect"
|
|
3100
|
+
* import { Data, Effect, pipe } from "effect"
|
|
3059
3101
|
* import { Console } from "effect"
|
|
3060
3102
|
*
|
|
3103
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3104
|
+
*
|
|
3061
3105
|
* // Function to apply a discount safely to a transaction amount
|
|
3062
3106
|
* const applyDiscount = (
|
|
3063
3107
|
* total: number,
|
|
3064
3108
|
* discountRate: number
|
|
3065
|
-
* ): Effect.Effect<number,
|
|
3109
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
3066
3110
|
* discountRate === 0
|
|
3067
|
-
* ? Effect.fail(new
|
|
3111
|
+
* ? Effect.fail(new DiscountRateError())
|
|
3068
3112
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
3069
3113
|
*
|
|
3070
3114
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -3114,16 +3158,18 @@ export declare const tap: {
|
|
|
3114
3158
|
* @example
|
|
3115
3159
|
* ```ts
|
|
3116
3160
|
* // Title: Logging a step in a pipeline
|
|
3117
|
-
* import { Effect, pipe } from "effect"
|
|
3161
|
+
* import { Data, Effect, pipe } from "effect"
|
|
3118
3162
|
* import { Console } from "effect"
|
|
3119
3163
|
*
|
|
3164
|
+
* class DiscountRateError extends Data.TaggedError("DiscountRateError")<{}> {}
|
|
3165
|
+
*
|
|
3120
3166
|
* // Function to apply a discount safely to a transaction amount
|
|
3121
3167
|
* const applyDiscount = (
|
|
3122
3168
|
* total: number,
|
|
3123
3169
|
* discountRate: number
|
|
3124
|
-
* ): Effect.Effect<number,
|
|
3170
|
+
* ): Effect.Effect<number, DiscountRateError> =>
|
|
3125
3171
|
* discountRate === 0
|
|
3126
|
-
* ? Effect.fail(new
|
|
3172
|
+
* ? Effect.fail(new DiscountRateError())
|
|
3127
3173
|
* : Effect.succeed(total - (total * discountRate) / 100)
|
|
3128
3174
|
*
|
|
3129
3175
|
* // Simulated asynchronous task to fetch a transaction amount from database
|
|
@@ -5278,17 +5324,19 @@ export declare const catchCauseFilter: {
|
|
|
5278
5324
|
*
|
|
5279
5325
|
* @example
|
|
5280
5326
|
* ```ts
|
|
5281
|
-
* import { Effect } from "effect"
|
|
5327
|
+
* import { Data, Effect } from "effect"
|
|
5328
|
+
*
|
|
5329
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5282
5330
|
*
|
|
5283
5331
|
* // ┌─── Effect<number, string, never>
|
|
5284
5332
|
* // ▼
|
|
5285
5333
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5286
5334
|
*
|
|
5287
|
-
* // ┌─── Effect<number,
|
|
5335
|
+
* // ┌─── Effect<number, TaskError, never>
|
|
5288
5336
|
* // ▼
|
|
5289
5337
|
* const mapped = Effect.mapError(
|
|
5290
5338
|
* simulatedTask,
|
|
5291
|
-
* (message) => new
|
|
5339
|
+
* (message) => new TaskError({ message })
|
|
5292
5340
|
* )
|
|
5293
5341
|
* ```
|
|
5294
5342
|
*
|
|
@@ -5311,17 +5359,19 @@ export declare const mapError: {
|
|
|
5311
5359
|
*
|
|
5312
5360
|
* @example
|
|
5313
5361
|
* ```ts
|
|
5314
|
-
* import { Effect } from "effect"
|
|
5362
|
+
* import { Data, Effect } from "effect"
|
|
5363
|
+
*
|
|
5364
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5315
5365
|
*
|
|
5316
5366
|
* // ┌─── Effect<number, string, never>
|
|
5317
5367
|
* // ▼
|
|
5318
5368
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5319
5369
|
*
|
|
5320
|
-
* // ┌─── Effect<number,
|
|
5370
|
+
* // ┌─── Effect<number, TaskError, never>
|
|
5321
5371
|
* // ▼
|
|
5322
5372
|
* const mapped = Effect.mapError(
|
|
5323
5373
|
* simulatedTask,
|
|
5324
|
-
* (message) => new
|
|
5374
|
+
* (message) => new TaskError({ message })
|
|
5325
5375
|
* )
|
|
5326
5376
|
* ```
|
|
5327
5377
|
*
|
|
@@ -5344,17 +5394,19 @@ export declare const mapError: {
|
|
|
5344
5394
|
*
|
|
5345
5395
|
* @example
|
|
5346
5396
|
* ```ts
|
|
5347
|
-
* import { Effect } from "effect"
|
|
5397
|
+
* import { Data, Effect } from "effect"
|
|
5398
|
+
*
|
|
5399
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5348
5400
|
*
|
|
5349
5401
|
* // ┌─── Effect<number, string, never>
|
|
5350
5402
|
* // ▼
|
|
5351
5403
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5352
5404
|
*
|
|
5353
|
-
* // ┌─── Effect<number,
|
|
5405
|
+
* // ┌─── Effect<number, TaskError, never>
|
|
5354
5406
|
* // ▼
|
|
5355
5407
|
* const mapped = Effect.mapError(
|
|
5356
5408
|
* simulatedTask,
|
|
5357
|
-
* (message) => new
|
|
5409
|
+
* (message) => new TaskError({ message })
|
|
5358
5410
|
* )
|
|
5359
5411
|
* ```
|
|
5360
5412
|
*
|
|
@@ -5375,16 +5427,18 @@ export declare const mapError: {
|
|
|
5375
5427
|
*
|
|
5376
5428
|
* @example
|
|
5377
5429
|
* ```ts
|
|
5378
|
-
* import { Effect } from "effect"
|
|
5430
|
+
* import { Data, Effect } from "effect"
|
|
5431
|
+
*
|
|
5432
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5379
5433
|
*
|
|
5380
5434
|
* // ┌─── Effect<number, string, never>
|
|
5381
5435
|
* // ▼
|
|
5382
5436
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5383
5437
|
*
|
|
5384
|
-
* // ┌─── Effect<boolean,
|
|
5438
|
+
* // ┌─── Effect<boolean, TaskError, never>
|
|
5385
5439
|
* // ▼
|
|
5386
5440
|
* const modified = Effect.mapBoth(simulatedTask, {
|
|
5387
|
-
* onFailure: (message) => new
|
|
5441
|
+
* onFailure: (message) => new TaskError({ message }),
|
|
5388
5442
|
* onSuccess: (n) => n > 0
|
|
5389
5443
|
* })
|
|
5390
5444
|
* ```
|
|
@@ -5408,16 +5462,18 @@ export declare const mapBoth: {
|
|
|
5408
5462
|
*
|
|
5409
5463
|
* @example
|
|
5410
5464
|
* ```ts
|
|
5411
|
-
* import { Effect } from "effect"
|
|
5465
|
+
* import { Data, Effect } from "effect"
|
|
5466
|
+
*
|
|
5467
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5412
5468
|
*
|
|
5413
5469
|
* // ┌─── Effect<number, string, never>
|
|
5414
5470
|
* // ▼
|
|
5415
5471
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5416
5472
|
*
|
|
5417
|
-
* // ┌─── Effect<boolean,
|
|
5473
|
+
* // ┌─── Effect<boolean, TaskError, never>
|
|
5418
5474
|
* // ▼
|
|
5419
5475
|
* const modified = Effect.mapBoth(simulatedTask, {
|
|
5420
|
-
* onFailure: (message) => new
|
|
5476
|
+
* onFailure: (message) => new TaskError({ message }),
|
|
5421
5477
|
* onSuccess: (n) => n > 0
|
|
5422
5478
|
* })
|
|
5423
5479
|
* ```
|
|
@@ -5444,16 +5500,18 @@ export declare const mapBoth: {
|
|
|
5444
5500
|
*
|
|
5445
5501
|
* @example
|
|
5446
5502
|
* ```ts
|
|
5447
|
-
* import { Effect } from "effect"
|
|
5503
|
+
* import { Data, Effect } from "effect"
|
|
5504
|
+
*
|
|
5505
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
5448
5506
|
*
|
|
5449
5507
|
* // ┌─── Effect<number, string, never>
|
|
5450
5508
|
* // ▼
|
|
5451
5509
|
* const simulatedTask = Effect.fail("Oh no!").pipe(Effect.as(1))
|
|
5452
5510
|
*
|
|
5453
|
-
* // ┌─── Effect<boolean,
|
|
5511
|
+
* // ┌─── Effect<boolean, TaskError, never>
|
|
5454
5512
|
* // ▼
|
|
5455
5513
|
* const modified = Effect.mapBoth(simulatedTask, {
|
|
5456
|
-
* onFailure: (message) => new
|
|
5514
|
+
* onFailure: (message) => new TaskError({ message }),
|
|
5457
5515
|
* onSuccess: (n) => n > 0
|
|
5458
5516
|
* })
|
|
5459
5517
|
* ```
|
|
@@ -5487,11 +5545,13 @@ export declare const mapBoth: {
|
|
|
5487
5545
|
* @example
|
|
5488
5546
|
* ```ts
|
|
5489
5547
|
* // Title: Propagating an Error as a Defect
|
|
5490
|
-
* import { Effect } from "effect"
|
|
5548
|
+
* import { Data, Effect } from "effect"
|
|
5549
|
+
*
|
|
5550
|
+
* class DivideByZeroError extends Data.TaggedError("DivideByZeroError")<{}> {}
|
|
5491
5551
|
*
|
|
5492
5552
|
* const divide = (a: number, b: number) =>
|
|
5493
5553
|
* b === 0
|
|
5494
|
-
* ? Effect.fail(new
|
|
5554
|
+
* ? Effect.fail(new DivideByZeroError())
|
|
5495
5555
|
* : Effect.succeed(a / b)
|
|
5496
5556
|
*
|
|
5497
5557
|
* // ┌─── Effect<number, never, never>
|
|
@@ -5500,7 +5560,7 @@ export declare const mapBoth: {
|
|
|
5500
5560
|
*
|
|
5501
5561
|
* Effect.runPromise(program).catch(console.error)
|
|
5502
5562
|
* // Output:
|
|
5503
|
-
* // (FiberFailure)
|
|
5563
|
+
* // (FiberFailure) DivideByZeroError
|
|
5504
5564
|
* // ...stack trace...
|
|
5505
5565
|
* ```
|
|
5506
5566
|
*
|
|
@@ -6205,13 +6265,15 @@ export declare namespace Retry {
|
|
|
6205
6265
|
*
|
|
6206
6266
|
* @example
|
|
6207
6267
|
* ```ts
|
|
6208
|
-
* import { Effect, Schedule } from "effect"
|
|
6268
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6269
|
+
*
|
|
6270
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6209
6271
|
*
|
|
6210
6272
|
* let attempt = 0
|
|
6211
|
-
* const task = Effect.callback<string,
|
|
6273
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6212
6274
|
* attempt++
|
|
6213
6275
|
* if (attempt <= 2) {
|
|
6214
|
-
* resume(Effect.fail(new
|
|
6276
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6215
6277
|
* } else {
|
|
6216
6278
|
* resume(Effect.succeed("Success!"))
|
|
6217
6279
|
* }
|
|
@@ -6254,13 +6316,15 @@ export declare const retry: {
|
|
|
6254
6316
|
*
|
|
6255
6317
|
* @example
|
|
6256
6318
|
* ```ts
|
|
6257
|
-
* import { Effect, Schedule } from "effect"
|
|
6319
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6320
|
+
*
|
|
6321
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6258
6322
|
*
|
|
6259
6323
|
* let attempt = 0
|
|
6260
|
-
* const task = Effect.callback<string,
|
|
6324
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6261
6325
|
* attempt++
|
|
6262
6326
|
* if (attempt <= 2) {
|
|
6263
|
-
* resume(Effect.fail(new
|
|
6327
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6264
6328
|
* } else {
|
|
6265
6329
|
* resume(Effect.succeed("Success!"))
|
|
6266
6330
|
* }
|
|
@@ -6303,13 +6367,15 @@ export declare const retry: {
|
|
|
6303
6367
|
*
|
|
6304
6368
|
* @example
|
|
6305
6369
|
* ```ts
|
|
6306
|
-
* import { Effect, Schedule } from "effect"
|
|
6370
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6371
|
+
*
|
|
6372
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6307
6373
|
*
|
|
6308
6374
|
* let attempt = 0
|
|
6309
|
-
* const task = Effect.callback<string,
|
|
6375
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6310
6376
|
* attempt++
|
|
6311
6377
|
* if (attempt <= 2) {
|
|
6312
|
-
* resume(Effect.fail(new
|
|
6378
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6313
6379
|
* } else {
|
|
6314
6380
|
* resume(Effect.succeed("Success!"))
|
|
6315
6381
|
* }
|
|
@@ -6352,13 +6418,15 @@ export declare const retry: {
|
|
|
6352
6418
|
*
|
|
6353
6419
|
* @example
|
|
6354
6420
|
* ```ts
|
|
6355
|
-
* import { Effect, Schedule } from "effect"
|
|
6421
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6422
|
+
*
|
|
6423
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6356
6424
|
*
|
|
6357
6425
|
* let attempt = 0
|
|
6358
|
-
* const task = Effect.callback<string,
|
|
6426
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6359
6427
|
* attempt++
|
|
6360
6428
|
* if (attempt <= 2) {
|
|
6361
|
-
* resume(Effect.fail(new
|
|
6429
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6362
6430
|
* } else {
|
|
6363
6431
|
* resume(Effect.succeed("Success!"))
|
|
6364
6432
|
* }
|
|
@@ -6401,13 +6469,15 @@ export declare const retry: {
|
|
|
6401
6469
|
*
|
|
6402
6470
|
* @example
|
|
6403
6471
|
* ```ts
|
|
6404
|
-
* import { Effect, Schedule } from "effect"
|
|
6472
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6473
|
+
*
|
|
6474
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6405
6475
|
*
|
|
6406
6476
|
* let attempt = 0
|
|
6407
|
-
* const task = Effect.callback<string,
|
|
6477
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6408
6478
|
* attempt++
|
|
6409
6479
|
* if (attempt <= 2) {
|
|
6410
|
-
* resume(Effect.fail(new
|
|
6480
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6411
6481
|
* } else {
|
|
6412
6482
|
* resume(Effect.succeed("Success!"))
|
|
6413
6483
|
* }
|
|
@@ -6450,13 +6520,15 @@ export declare const retry: {
|
|
|
6450
6520
|
*
|
|
6451
6521
|
* @example
|
|
6452
6522
|
* ```ts
|
|
6453
|
-
* import { Effect, Schedule } from "effect"
|
|
6523
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6524
|
+
*
|
|
6525
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6454
6526
|
*
|
|
6455
6527
|
* let attempt = 0
|
|
6456
|
-
* const task = Effect.callback<string,
|
|
6528
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6457
6529
|
* attempt++
|
|
6458
6530
|
* if (attempt <= 2) {
|
|
6459
|
-
* resume(Effect.fail(new
|
|
6531
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6460
6532
|
* } else {
|
|
6461
6533
|
* resume(Effect.succeed("Success!"))
|
|
6462
6534
|
* }
|
|
@@ -6499,13 +6571,15 @@ export declare const retry: {
|
|
|
6499
6571
|
*
|
|
6500
6572
|
* @example
|
|
6501
6573
|
* ```ts
|
|
6502
|
-
* import { Effect, Schedule } from "effect"
|
|
6574
|
+
* import { Data, Effect, Schedule } from "effect"
|
|
6575
|
+
*
|
|
6576
|
+
* class AttemptError extends Data.TaggedError("AttemptError")<{ readonly attempt: number }> {}
|
|
6503
6577
|
*
|
|
6504
6578
|
* let attempt = 0
|
|
6505
|
-
* const task = Effect.callback<string,
|
|
6579
|
+
* const task = Effect.callback<string, AttemptError>((resume) => {
|
|
6506
6580
|
* attempt++
|
|
6507
6581
|
* if (attempt <= 2) {
|
|
6508
|
-
* resume(Effect.fail(new
|
|
6582
|
+
* resume(Effect.fail(new AttemptError({ attempt })))
|
|
6509
6583
|
* } else {
|
|
6510
6584
|
* resume(Effect.succeed("Success!"))
|
|
6511
6585
|
* }
|
|
@@ -6546,14 +6620,16 @@ export declare const retry: {
|
|
|
6546
6620
|
*
|
|
6547
6621
|
* @example
|
|
6548
6622
|
* ```ts
|
|
6549
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
6623
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
6624
|
+
*
|
|
6625
|
+
* class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
|
|
6550
6626
|
*
|
|
6551
6627
|
* let attempt = 0
|
|
6552
6628
|
* const networkRequest = Effect.gen(function*() {
|
|
6553
6629
|
* attempt++
|
|
6554
6630
|
* yield* Console.log(`Network attempt ${attempt}`)
|
|
6555
6631
|
* if (attempt < 3) {
|
|
6556
|
-
* return yield* Effect.fail(new
|
|
6632
|
+
* return yield* Effect.fail(new NetworkTimeoutError())
|
|
6557
6633
|
* }
|
|
6558
6634
|
* return "Network data"
|
|
6559
6635
|
* })
|
|
@@ -6601,14 +6677,16 @@ export declare const retryOrElse: {
|
|
|
6601
6677
|
*
|
|
6602
6678
|
* @example
|
|
6603
6679
|
* ```ts
|
|
6604
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
6680
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
6681
|
+
*
|
|
6682
|
+
* class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
|
|
6605
6683
|
*
|
|
6606
6684
|
* let attempt = 0
|
|
6607
6685
|
* const networkRequest = Effect.gen(function*() {
|
|
6608
6686
|
* attempt++
|
|
6609
6687
|
* yield* Console.log(`Network attempt ${attempt}`)
|
|
6610
6688
|
* if (attempt < 3) {
|
|
6611
|
-
* return yield* Effect.fail(new
|
|
6689
|
+
* return yield* Effect.fail(new NetworkTimeoutError())
|
|
6612
6690
|
* }
|
|
6613
6691
|
* return "Network data"
|
|
6614
6692
|
* })
|
|
@@ -6656,14 +6734,16 @@ export declare const retryOrElse: {
|
|
|
6656
6734
|
*
|
|
6657
6735
|
* @example
|
|
6658
6736
|
* ```ts
|
|
6659
|
-
* import { Console, Effect, Schedule } from "effect"
|
|
6737
|
+
* import { Console, Data, Effect, Schedule } from "effect"
|
|
6738
|
+
*
|
|
6739
|
+
* class NetworkTimeoutError extends Data.TaggedError("NetworkTimeoutError")<{}> {}
|
|
6660
6740
|
*
|
|
6661
6741
|
* let attempt = 0
|
|
6662
6742
|
* const networkRequest = Effect.gen(function*() {
|
|
6663
6743
|
* attempt++
|
|
6664
6744
|
* yield* Console.log(`Network attempt ${attempt}`)
|
|
6665
6745
|
* if (attempt < 3) {
|
|
6666
|
-
* return yield* Effect.fail(new
|
|
6746
|
+
* return yield* Effect.fail(new NetworkTimeoutError())
|
|
6667
6747
|
* }
|
|
6668
6748
|
* return "Network data"
|
|
6669
6749
|
* })
|
|
@@ -8673,9 +8753,11 @@ export declare const when: {
|
|
|
8673
8753
|
* @example
|
|
8674
8754
|
* ```ts
|
|
8675
8755
|
* // Title: Handling Both Success and Failure Cases
|
|
8676
|
-
* import { Effect } from "effect"
|
|
8756
|
+
* import { Data, Effect } from "effect"
|
|
8757
|
+
*
|
|
8758
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
8677
8759
|
*
|
|
8678
|
-
* const success: Effect.Effect<number,
|
|
8760
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
8679
8761
|
*
|
|
8680
8762
|
* const program1 = Effect.match(success, {
|
|
8681
8763
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -8686,8 +8768,8 @@ export declare const when: {
|
|
|
8686
8768
|
* Effect.runPromise(program1).then(console.log)
|
|
8687
8769
|
* // Output: "success: 42"
|
|
8688
8770
|
*
|
|
8689
|
-
* const failure: Effect.Effect<number,
|
|
8690
|
-
* new
|
|
8771
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
8772
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
8691
8773
|
* )
|
|
8692
8774
|
*
|
|
8693
8775
|
* const program2 = Effect.match(failure, {
|
|
@@ -8725,9 +8807,11 @@ export declare const match: {
|
|
|
8725
8807
|
* @example
|
|
8726
8808
|
* ```ts
|
|
8727
8809
|
* // Title: Handling Both Success and Failure Cases
|
|
8728
|
-
* import { Effect } from "effect"
|
|
8810
|
+
* import { Data, Effect } from "effect"
|
|
8729
8811
|
*
|
|
8730
|
-
*
|
|
8812
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
8813
|
+
*
|
|
8814
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
8731
8815
|
*
|
|
8732
8816
|
* const program1 = Effect.match(success, {
|
|
8733
8817
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -8738,8 +8822,8 @@ export declare const match: {
|
|
|
8738
8822
|
* Effect.runPromise(program1).then(console.log)
|
|
8739
8823
|
* // Output: "success: 42"
|
|
8740
8824
|
*
|
|
8741
|
-
* const failure: Effect.Effect<number,
|
|
8742
|
-
* new
|
|
8825
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
8826
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
8743
8827
|
* )
|
|
8744
8828
|
*
|
|
8745
8829
|
* const program2 = Effect.match(failure, {
|
|
@@ -8780,9 +8864,11 @@ export declare const match: {
|
|
|
8780
8864
|
* @example
|
|
8781
8865
|
* ```ts
|
|
8782
8866
|
* // Title: Handling Both Success and Failure Cases
|
|
8783
|
-
* import { Effect } from "effect"
|
|
8867
|
+
* import { Data, Effect } from "effect"
|
|
8868
|
+
*
|
|
8869
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
8784
8870
|
*
|
|
8785
|
-
* const success: Effect.Effect<number,
|
|
8871
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
8786
8872
|
*
|
|
8787
8873
|
* const program1 = Effect.match(success, {
|
|
8788
8874
|
* onFailure: (error) => `failure: ${error.message}`,
|
|
@@ -8793,8 +8879,8 @@ export declare const match: {
|
|
|
8793
8879
|
* Effect.runPromise(program1).then(console.log)
|
|
8794
8880
|
* // Output: "success: 42"
|
|
8795
8881
|
*
|
|
8796
|
-
* const failure: Effect.Effect<number,
|
|
8797
|
-
* new
|
|
8882
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
8883
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
8798
8884
|
* )
|
|
8799
8885
|
*
|
|
8800
8886
|
* const program2 = Effect.match(failure, {
|
|
@@ -9196,9 +9282,11 @@ export declare const matchCauseEffectEager: {
|
|
|
9196
9282
|
*
|
|
9197
9283
|
* @example
|
|
9198
9284
|
* ```ts
|
|
9199
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
9285
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
9200
9286
|
*
|
|
9201
|
-
*
|
|
9287
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
9288
|
+
*
|
|
9289
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
9202
9290
|
*
|
|
9203
9291
|
* const program = Effect.matchCauseEffect(task, {
|
|
9204
9292
|
* onFailure: (cause) =>
|
|
@@ -9248,9 +9336,11 @@ export declare const matchCauseEffect: {
|
|
|
9248
9336
|
*
|
|
9249
9337
|
* @example
|
|
9250
9338
|
* ```ts
|
|
9251
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
9339
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
9340
|
+
*
|
|
9341
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
9252
9342
|
*
|
|
9253
|
-
* const task = Effect.fail(new
|
|
9343
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
9254
9344
|
*
|
|
9255
9345
|
* const program = Effect.matchCauseEffect(task, {
|
|
9256
9346
|
* onFailure: (cause) =>
|
|
@@ -9303,9 +9393,11 @@ export declare const matchCauseEffect: {
|
|
|
9303
9393
|
*
|
|
9304
9394
|
* @example
|
|
9305
9395
|
* ```ts
|
|
9306
|
-
* import { Cause, Console, Effect, Result } from "effect"
|
|
9396
|
+
* import { Cause, Console, Data, Effect, Result } from "effect"
|
|
9307
9397
|
*
|
|
9308
|
-
*
|
|
9398
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
9399
|
+
*
|
|
9400
|
+
* const task = Effect.fail(new TaskError({ message: "Task failed" }))
|
|
9309
9401
|
*
|
|
9310
9402
|
* const program = Effect.matchCauseEffect(task, {
|
|
9311
9403
|
* onFailure: (cause) =>
|
|
@@ -9365,11 +9457,13 @@ export declare const matchCauseEffect: {
|
|
|
9365
9457
|
* @example
|
|
9366
9458
|
* ```ts
|
|
9367
9459
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9368
|
-
* import { Effect } from "effect"
|
|
9460
|
+
* import { Data, Effect } from "effect"
|
|
9369
9461
|
*
|
|
9370
|
-
*
|
|
9371
|
-
*
|
|
9372
|
-
*
|
|
9462
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9463
|
+
*
|
|
9464
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9465
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9466
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9373
9467
|
* )
|
|
9374
9468
|
*
|
|
9375
9469
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9425,11 +9519,13 @@ export declare const matchEffect: {
|
|
|
9425
9519
|
* @example
|
|
9426
9520
|
* ```ts
|
|
9427
9521
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9428
|
-
* import { Effect } from "effect"
|
|
9522
|
+
* import { Data, Effect } from "effect"
|
|
9523
|
+
*
|
|
9524
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9429
9525
|
*
|
|
9430
|
-
* const success: Effect.Effect<number,
|
|
9431
|
-
* const failure: Effect.Effect<number,
|
|
9432
|
-
* new
|
|
9526
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9527
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9528
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9433
9529
|
* )
|
|
9434
9530
|
*
|
|
9435
9531
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -9488,11 +9584,13 @@ export declare const matchEffect: {
|
|
|
9488
9584
|
* @example
|
|
9489
9585
|
* ```ts
|
|
9490
9586
|
* // Title: Handling Both Success and Failure Cases with Side Effects
|
|
9491
|
-
* import { Effect } from "effect"
|
|
9587
|
+
* import { Data, Effect } from "effect"
|
|
9492
9588
|
*
|
|
9493
|
-
*
|
|
9494
|
-
*
|
|
9495
|
-
*
|
|
9589
|
+
* class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
|
|
9590
|
+
*
|
|
9591
|
+
* const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
|
|
9592
|
+
* const failure: Effect.Effect<number, ExampleError> = Effect.fail(
|
|
9593
|
+
* new ExampleError({ message: "Uh oh!" })
|
|
9496
9594
|
* )
|
|
9497
9595
|
*
|
|
9498
9596
|
* const program1 = Effect.matchEffect(success, {
|
|
@@ -11238,9 +11336,11 @@ export declare const ensuring: {
|
|
|
11238
11336
|
*
|
|
11239
11337
|
* @example
|
|
11240
11338
|
* ```ts
|
|
11241
|
-
* import { Cause, Console, Effect } from "effect"
|
|
11339
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
11242
11340
|
*
|
|
11243
|
-
*
|
|
11341
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
11342
|
+
*
|
|
11343
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
11244
11344
|
*
|
|
11245
11345
|
* const program = Effect.onError(
|
|
11246
11346
|
* task,
|
|
@@ -11249,8 +11349,8 @@ export declare const ensuring: {
|
|
|
11249
11349
|
*
|
|
11250
11350
|
* Effect.runPromise(program).catch(console.error)
|
|
11251
11351
|
* // Output:
|
|
11252
|
-
* // Cleanup on error:
|
|
11253
|
-
* //
|
|
11352
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
11353
|
+
* // TaskError: Something went wrong
|
|
11254
11354
|
* ```
|
|
11255
11355
|
*
|
|
11256
11356
|
* @since 2.0.0
|
|
@@ -11263,9 +11363,11 @@ export declare const onError: {
|
|
|
11263
11363
|
*
|
|
11264
11364
|
* @example
|
|
11265
11365
|
* ```ts
|
|
11266
|
-
* import { Cause, Console, Effect } from "effect"
|
|
11366
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
11267
11367
|
*
|
|
11268
|
-
*
|
|
11368
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
11369
|
+
*
|
|
11370
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
11269
11371
|
*
|
|
11270
11372
|
* const program = Effect.onError(
|
|
11271
11373
|
* task,
|
|
@@ -11274,8 +11376,8 @@ export declare const onError: {
|
|
|
11274
11376
|
*
|
|
11275
11377
|
* Effect.runPromise(program).catch(console.error)
|
|
11276
11378
|
* // Output:
|
|
11277
|
-
* // Cleanup on error:
|
|
11278
|
-
* //
|
|
11379
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
11380
|
+
* // TaskError: Something went wrong
|
|
11279
11381
|
* ```
|
|
11280
11382
|
*
|
|
11281
11383
|
* @since 2.0.0
|
|
@@ -11288,9 +11390,11 @@ export declare const onError: {
|
|
|
11288
11390
|
*
|
|
11289
11391
|
* @example
|
|
11290
11392
|
* ```ts
|
|
11291
|
-
* import { Cause, Console, Effect } from "effect"
|
|
11393
|
+
* import { Cause, Data, Console, Effect } from "effect"
|
|
11292
11394
|
*
|
|
11293
|
-
*
|
|
11395
|
+
* class TaskError extends Data.TaggedError("TaskError")<{ readonly message: string }> {}
|
|
11396
|
+
*
|
|
11397
|
+
* const task = Effect.fail(new TaskError({ message: "Something went wrong" }))
|
|
11294
11398
|
*
|
|
11295
11399
|
* const program = Effect.onError(
|
|
11296
11400
|
* task,
|
|
@@ -11299,8 +11403,8 @@ export declare const onError: {
|
|
|
11299
11403
|
*
|
|
11300
11404
|
* Effect.runPromise(program).catch(console.error)
|
|
11301
11405
|
* // Output:
|
|
11302
|
-
* // Cleanup on error:
|
|
11303
|
-
* //
|
|
11406
|
+
* // Cleanup on error: TaskError: Something went wrong
|
|
11407
|
+
* // TaskError: Something went wrong
|
|
11304
11408
|
* ```
|
|
11305
11409
|
*
|
|
11306
11410
|
* @since 2.0.0
|
|
@@ -14337,7 +14441,7 @@ export declare const withParentSpan: {
|
|
|
14337
14441
|
* )
|
|
14338
14442
|
*
|
|
14339
14443
|
* const program = Effect.gen(function*() {
|
|
14340
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
14444
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
14341
14445
|
* yield* Console.log(name)
|
|
14342
14446
|
* })
|
|
14343
14447
|
* ```
|
|
@@ -14368,7 +14472,7 @@ export declare const request: {
|
|
|
14368
14472
|
* )
|
|
14369
14473
|
*
|
|
14370
14474
|
* const program = Effect.gen(function*() {
|
|
14371
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
14475
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
14372
14476
|
* yield* Console.log(name)
|
|
14373
14477
|
* })
|
|
14374
14478
|
* ```
|
|
@@ -14399,7 +14503,7 @@ export declare const request: {
|
|
|
14399
14503
|
* )
|
|
14400
14504
|
*
|
|
14401
14505
|
* const program = Effect.gen(function*() {
|
|
14402
|
-
* const name = yield* Effect.request(GetUser({ id: 1 }),
|
|
14506
|
+
* const name = yield* Effect.request(GetUser({ id: 1 }), resolver)
|
|
14403
14507
|
* yield* Console.log(name)
|
|
14404
14508
|
* })
|
|
14405
14509
|
* ```
|
|
@@ -16795,18 +16899,20 @@ export declare const trackSuccesses: {
|
|
|
16795
16899
|
*
|
|
16796
16900
|
* @example
|
|
16797
16901
|
* ```ts
|
|
16798
|
-
* import { Effect, Metric } from "effect"
|
|
16902
|
+
* import { Data, Effect, Metric } from "effect"
|
|
16903
|
+
*
|
|
16904
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16799
16905
|
*
|
|
16800
16906
|
* // Track error types using frequency metric
|
|
16801
16907
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16802
16908
|
*
|
|
16803
|
-
* const program = Effect.fail(new
|
|
16804
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
16909
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
16910
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16805
16911
|
* )
|
|
16806
16912
|
*
|
|
16807
16913
|
* Effect.runPromiseExit(program).then(() =>
|
|
16808
16914
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16809
|
-
* // Output: { occurrences: Map(1) { "
|
|
16915
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16810
16916
|
* )
|
|
16811
16917
|
* ```
|
|
16812
16918
|
*
|
|
@@ -16841,18 +16947,20 @@ export declare const trackErrors: {
|
|
|
16841
16947
|
*
|
|
16842
16948
|
* @example
|
|
16843
16949
|
* ```ts
|
|
16844
|
-
* import { Effect, Metric } from "effect"
|
|
16950
|
+
* import { Data, Effect, Metric } from "effect"
|
|
16951
|
+
*
|
|
16952
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16845
16953
|
*
|
|
16846
16954
|
* // Track error types using frequency metric
|
|
16847
16955
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16848
16956
|
*
|
|
16849
|
-
* const program = Effect.fail(new
|
|
16850
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
16957
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
16958
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16851
16959
|
* )
|
|
16852
16960
|
*
|
|
16853
16961
|
* Effect.runPromiseExit(program).then(() =>
|
|
16854
16962
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16855
|
-
* // Output: { occurrences: Map(1) { "
|
|
16963
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16856
16964
|
* )
|
|
16857
16965
|
* ```
|
|
16858
16966
|
*
|
|
@@ -16887,18 +16995,20 @@ export declare const trackErrors: {
|
|
|
16887
16995
|
*
|
|
16888
16996
|
* @example
|
|
16889
16997
|
* ```ts
|
|
16890
|
-
* import { Effect, Metric } from "effect"
|
|
16998
|
+
* import { Data, Effect, Metric } from "effect"
|
|
16999
|
+
*
|
|
17000
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16891
17001
|
*
|
|
16892
17002
|
* // Track error types using frequency metric
|
|
16893
17003
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16894
17004
|
*
|
|
16895
|
-
* const program = Effect.fail(new
|
|
16896
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17005
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17006
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16897
17007
|
* )
|
|
16898
17008
|
*
|
|
16899
17009
|
* Effect.runPromiseExit(program).then(() =>
|
|
16900
17010
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16901
|
-
* // Output: { occurrences: Map(1) { "
|
|
17011
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16902
17012
|
* )
|
|
16903
17013
|
* ```
|
|
16904
17014
|
*
|
|
@@ -16933,18 +17043,20 @@ export declare const trackErrors: {
|
|
|
16933
17043
|
*
|
|
16934
17044
|
* @example
|
|
16935
17045
|
* ```ts
|
|
16936
|
-
* import { Effect, Metric } from "effect"
|
|
17046
|
+
* import { Data, Effect, Metric } from "effect"
|
|
17047
|
+
*
|
|
17048
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16937
17049
|
*
|
|
16938
17050
|
* // Track error types using frequency metric
|
|
16939
17051
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16940
17052
|
*
|
|
16941
|
-
* const program = Effect.fail(new
|
|
16942
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17053
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17054
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16943
17055
|
* )
|
|
16944
17056
|
*
|
|
16945
17057
|
* Effect.runPromiseExit(program).then(() =>
|
|
16946
17058
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16947
|
-
* // Output: { occurrences: Map(1) { "
|
|
17059
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16948
17060
|
* )
|
|
16949
17061
|
* ```
|
|
16950
17062
|
*
|
|
@@ -16979,18 +17091,20 @@ export declare const trackErrors: {
|
|
|
16979
17091
|
*
|
|
16980
17092
|
* @example
|
|
16981
17093
|
* ```ts
|
|
16982
|
-
* import { Effect, Metric } from "effect"
|
|
17094
|
+
* import { Data, Effect, Metric } from "effect"
|
|
17095
|
+
*
|
|
17096
|
+
* class ConnectionFailedError extends Data.TaggedError("ConnectionFailedError")<{}> {}
|
|
16983
17097
|
*
|
|
16984
17098
|
* // Track error types using frequency metric
|
|
16985
17099
|
* const errorTypeFrequency = Metric.frequency("error_types")
|
|
16986
17100
|
*
|
|
16987
|
-
* const program = Effect.fail(new
|
|
16988
|
-
* Effect.trackErrors(errorTypeFrequency, (error:
|
|
17101
|
+
* const program = Effect.fail(new ConnectionFailedError()).pipe(
|
|
17102
|
+
* Effect.trackErrors(errorTypeFrequency, (error: ConnectionFailedError) => error._tag)
|
|
16989
17103
|
* )
|
|
16990
17104
|
*
|
|
16991
17105
|
* Effect.runPromiseExit(program).then(() =>
|
|
16992
17106
|
* Effect.runPromise(Metric.value(errorTypeFrequency)).then(console.log)
|
|
16993
|
-
* // Output: { occurrences: Map(1) { "
|
|
17107
|
+
* // Output: { occurrences: Map(1) { "ConnectionFailedError" => 1 } }
|
|
16994
17108
|
* )
|
|
16995
17109
|
* ```
|
|
16996
17110
|
*
|
|
@@ -18065,18 +18179,20 @@ export declare const satisfiesSuccessType: <A>() => <A2 extends A, E, R>(effect:
|
|
|
18065
18179
|
*
|
|
18066
18180
|
* @example
|
|
18067
18181
|
* ```ts
|
|
18068
|
-
* import { Effect } from "effect"
|
|
18182
|
+
* import { Data, Effect } from "effect"
|
|
18183
|
+
*
|
|
18184
|
+
* class ValidationError extends Data.TaggedError("ValidationError")<{}> {}
|
|
18069
18185
|
*
|
|
18070
|
-
* // Define a constraint that the error type must be
|
|
18071
|
-
* const satisfiesError = Effect.satisfiesErrorType<
|
|
18186
|
+
* // Define a constraint that the error type must be a ValidationError
|
|
18187
|
+
* const satisfiesError = Effect.satisfiesErrorType<ValidationError>()
|
|
18072
18188
|
*
|
|
18073
|
-
* // This works - Effect<number,
|
|
18074
|
-
* const validEffect = satisfiesError(Effect.fail(new
|
|
18189
|
+
* // This works - Effect<number, ValidationError, never> extends the constrained type
|
|
18190
|
+
* const validEffect = satisfiesError(Effect.fail(new ValidationError()))
|
|
18075
18191
|
*
|
|
18076
18192
|
* // This would cause a TypeScript compilation error:
|
|
18077
18193
|
* // const invalidEffect = satisfiesError(Effect.fail("string error"))
|
|
18078
18194
|
* // ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
18079
|
-
* // Type 'string' is not assignable to type '
|
|
18195
|
+
* // Type 'string' is not assignable to type 'ValidationError'
|
|
18080
18196
|
* ```
|
|
18081
18197
|
*
|
|
18082
18198
|
* @since 4.0.0
|