effect 3.1.6 → 3.2.0

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.
Files changed (105) hide show
  1. package/dist/cjs/Array.js +139 -2
  2. package/dist/cjs/Array.js.map +1 -1
  3. package/dist/cjs/Cause.js +8 -1
  4. package/dist/cjs/Cause.js.map +1 -1
  5. package/dist/cjs/Chunk.js +18 -1
  6. package/dist/cjs/Chunk.js.map +1 -1
  7. package/dist/cjs/Data.js +11 -8
  8. package/dist/cjs/Data.js.map +1 -1
  9. package/dist/cjs/Effect.js +20 -3
  10. package/dist/cjs/Effect.js.map +1 -1
  11. package/dist/cjs/Stream.js +19 -1
  12. package/dist/cjs/Stream.js.map +1 -1
  13. package/dist/cjs/Tracer.js.map +1 -1
  14. package/dist/cjs/internal/cause.js +55 -48
  15. package/dist/cjs/internal/cause.js.map +1 -1
  16. package/dist/cjs/internal/channel.js +11 -1
  17. package/dist/cjs/internal/channel.js.map +1 -1
  18. package/dist/cjs/internal/core-effect.js +51 -9
  19. package/dist/cjs/internal/core-effect.js.map +1 -1
  20. package/dist/cjs/internal/core.js +8 -4
  21. package/dist/cjs/internal/core.js.map +1 -1
  22. package/dist/cjs/internal/fiberRuntime.js +27 -14
  23. package/dist/cjs/internal/fiberRuntime.js.map +1 -1
  24. package/dist/cjs/internal/layer/circular.js +4 -1
  25. package/dist/cjs/internal/layer/circular.js.map +1 -1
  26. package/dist/cjs/internal/layer.js +11 -1
  27. package/dist/cjs/internal/layer.js.map +1 -1
  28. package/dist/cjs/internal/runtime.js +7 -4
  29. package/dist/cjs/internal/runtime.js.map +1 -1
  30. package/dist/cjs/internal/stream.js +27 -9
  31. package/dist/cjs/internal/stream.js.map +1 -1
  32. package/dist/cjs/internal/tracer.js +31 -1
  33. package/dist/cjs/internal/tracer.js.map +1 -1
  34. package/dist/cjs/internal/version.js +1 -1
  35. package/dist/dts/Array.d.ts +199 -0
  36. package/dist/dts/Array.d.ts.map +1 -1
  37. package/dist/dts/Cause.d.ts +15 -0
  38. package/dist/dts/Cause.d.ts.map +1 -1
  39. package/dist/dts/Chunk.d.ts +20 -0
  40. package/dist/dts/Chunk.d.ts.map +1 -1
  41. package/dist/dts/Data.d.ts +46 -13
  42. package/dist/dts/Data.d.ts.map +1 -1
  43. package/dist/dts/Effect.d.ts +36 -0
  44. package/dist/dts/Effect.d.ts.map +1 -1
  45. package/dist/dts/Stream.d.ts +23 -1
  46. package/dist/dts/Stream.d.ts.map +1 -1
  47. package/dist/dts/Tracer.d.ts +1 -0
  48. package/dist/dts/Tracer.d.ts.map +1 -1
  49. package/dist/dts/internal/core-effect.d.ts +7 -1
  50. package/dist/dts/internal/core-effect.d.ts.map +1 -1
  51. package/dist/dts/internal/core.d.ts.map +1 -1
  52. package/dist/dts/internal/stream.d.ts.map +1 -1
  53. package/dist/esm/Array.js +182 -0
  54. package/dist/esm/Array.js.map +1 -1
  55. package/dist/esm/Cause.js +7 -0
  56. package/dist/esm/Cause.js.map +1 -1
  57. package/dist/esm/Chunk.js +16 -0
  58. package/dist/esm/Chunk.js.map +1 -1
  59. package/dist/esm/Data.js +11 -8
  60. package/dist/esm/Data.js.map +1 -1
  61. package/dist/esm/Effect.js +17 -0
  62. package/dist/esm/Effect.js.map +1 -1
  63. package/dist/esm/Stream.js +18 -0
  64. package/dist/esm/Stream.js.map +1 -1
  65. package/dist/esm/Tracer.js.map +1 -1
  66. package/dist/esm/internal/cause.js +54 -47
  67. package/dist/esm/internal/cause.js.map +1 -1
  68. package/dist/esm/internal/channel.js +10 -1
  69. package/dist/esm/internal/channel.js.map +1 -1
  70. package/dist/esm/internal/core-effect.js +47 -7
  71. package/dist/esm/internal/core-effect.js.map +1 -1
  72. package/dist/esm/internal/core.js +7 -3
  73. package/dist/esm/internal/core.js.map +1 -1
  74. package/dist/esm/internal/fiberRuntime.js +26 -14
  75. package/dist/esm/internal/fiberRuntime.js.map +1 -1
  76. package/dist/esm/internal/layer/circular.js +4 -1
  77. package/dist/esm/internal/layer/circular.js.map +1 -1
  78. package/dist/esm/internal/layer.js +10 -1
  79. package/dist/esm/internal/layer.js.map +1 -1
  80. package/dist/esm/internal/runtime.js +7 -4
  81. package/dist/esm/internal/runtime.js.map +1 -1
  82. package/dist/esm/internal/stream.js +23 -7
  83. package/dist/esm/internal/stream.js.map +1 -1
  84. package/dist/esm/internal/tracer.js +29 -0
  85. package/dist/esm/internal/tracer.js.map +1 -1
  86. package/dist/esm/internal/version.js +1 -1
  87. package/package.json +1 -1
  88. package/src/Array.ts +214 -0
  89. package/src/Cause.ts +17 -0
  90. package/src/Chunk.ts +30 -0
  91. package/src/Data.ts +121 -48
  92. package/src/Effect.ts +40 -0
  93. package/src/Stream.ts +31 -1
  94. package/src/Tracer.ts +1 -0
  95. package/src/internal/cause.ts +70 -52
  96. package/src/internal/channel.ts +32 -14
  97. package/src/internal/core-effect.ts +74 -25
  98. package/src/internal/core.ts +8 -3
  99. package/src/internal/fiberRuntime.ts +22 -11
  100. package/src/internal/layer/circular.ts +4 -2
  101. package/src/internal/layer.ts +37 -14
  102. package/src/internal/runtime.ts +9 -4
  103. package/src/internal/stream.ts +37 -13
  104. package/src/internal/tracer.ts +21 -0
  105. package/src/internal/version.ts +1 -1
@@ -82,4 +82,33 @@ export const externalSpan = options => ({
82
82
  sampled: options.sampled ?? true,
83
83
  context: options.context ?? Context.empty()
84
84
  });
85
+ /** @internal */
86
+ export const addSpanStackTrace = options => {
87
+ if (options?.captureStackTrace === false) {
88
+ return options;
89
+ } else if (options?.captureStackTrace !== undefined && typeof options.captureStackTrace !== "boolean") {
90
+ return options;
91
+ }
92
+ const limit = Error.stackTraceLimit;
93
+ Error.stackTraceLimit = 3;
94
+ const traceError = new Error();
95
+ Error.stackTraceLimit = limit;
96
+ if (traceError.stack === undefined) {
97
+ return {
98
+ ...options,
99
+ captureStackTrace: false
100
+ };
101
+ }
102
+ const stack = traceError.stack.split("\n");
103
+ if (!stack[3]) {
104
+ return {
105
+ ...options,
106
+ captureStackTrace: false
107
+ };
108
+ }
109
+ return {
110
+ ...options,
111
+ captureStackTrace: stack[3].trim()
112
+ };
113
+ };
85
114
  //# sourceMappingURL=tracer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracer.js","names":["Context","TracerTypeId","Symbol","for","make","options","tracerTag","GenericTag","spanTag","randomHexString","characters","charactersLength","length","result","i","charAt","Math","floor","random","NativeSpan","name","parent","context","links","startTime","kind","_tag","spanId","traceId","sampled","status","attributes","events","constructor","Map","value","end","endTime","exit","attribute","key","set","event","push","nativeTracer","span","f","externalSpan","empty"],"sources":["../../../src/internal/tracer.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,OAAO,MAAM,eAAe;AAKxC;AACA,OAAO,MAAMC,YAAY,gBAAwBC,MAAM,CAACC,GAAG,CAAC,eAAe,CAAwB;AAEnG;AACA,OAAO,MAAMC,IAAI,GAAIC,OAAiD,KAAqB;EACzF,CAACJ,YAAY,GAAGA,YAAY;EAC5B,GAAGI;CACJ,CAAC;AAEF;AACA,OAAO,MAAMC,SAAS,gBAAGN,OAAO,CAACO,UAAU,CAAgB,eAAe,CAAC;AAE3E;AACA,OAAO,MAAMC,OAAO,gBAAGR,OAAO,CAACO,UAAU,CAAoC,mBAAmB,CAAC;AAEjG,MAAME,eAAe,gBAAI;EACvB,MAAMC,UAAU,GAAG,kBAAkB;EACrC,MAAMC,gBAAgB,GAAGD,UAAU,CAACE,MAAM;EAC1C,OAAO,UAASA,MAAc;IAC5B,IAAIC,MAAM,GAAG,EAAE;IACf,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,EAAEE,CAAC,EAAE,EAAE;MAC/BD,MAAM,IAAIH,UAAU,CAACK,MAAM,CAACC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,MAAM,EAAE,GAAGP,gBAAgB,CAAC,CAAC;IAC3E;IACA,OAAOE,MAAM;EACf,CAAC;AACH,CAAC,CAAC,CAAE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AI,EAAEI,SAAS,EAAEO,UAAU,IAAI,EAAE,CAAC,CAAC;EACvD;;AAGF;AACA,OAAO,MAAMa,YAAY,gBAAkBxC,IAAI,CAAC;EAC9CyC,IAAI,EAAEA,CAACzB,IAAI,EAAEC,MAAM,EAAEC,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAEC,IAAI,KAClD,IAAIN,UAAU,CACZC,IAAI,EACJC,MAAM,EACNC,OAAO,EACPC,KAAK,EACLC,SAAS,EACTC,IAAI,CACL;EACHH,OAAO,EAAGwB,CAAC,IAAKA,CAAC;CAClB,CAAC;AAEF;AACA,OAAO,MAAMC,YAAY,GAAI1C,OAK5B,KAA2B;EAC1BqB,IAAI,EAAE,cAAc;EACpBC,MAAM,EAAEtB,OAAO,CAACsB,MAAM;EACtBC,OAAO,EAAEvB,OAAO,CAACuB,OAAO;EACxBC,OAAO,EAAExB,OAAO,CAACwB,OAAO,IAAI,IAAI;EAChCP,OAAO,EAAEjB,OAAO,CAACiB,OAAO,IAAItB,OAAO,CAACgD,KAAK;CAC1C,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"tracer.js","names":["Context","TracerTypeId","Symbol","for","make","options","tracerTag","GenericTag","spanTag","randomHexString","characters","charactersLength","length","result","i","charAt","Math","floor","random","NativeSpan","name","parent","context","links","startTime","kind","_tag","spanId","traceId","sampled","status","attributes","events","constructor","Map","value","end","endTime","exit","attribute","key","set","event","push","nativeTracer","span","f","externalSpan","empty","addSpanStackTrace","captureStackTrace","undefined","limit","Error","stackTraceLimit","traceError","stack","split","trim"],"sources":["../../../src/internal/tracer.ts"],"sourcesContent":[null],"mappings":"AAAA;;;AAGA,OAAO,KAAKA,OAAO,MAAM,eAAe;AAKxC;AACA,OAAO,MAAMC,YAAY,gBAAwBC,MAAM,CAACC,GAAG,CAAC,eAAe,CAAwB;AAEnG;AACA,OAAO,MAAMC,IAAI,GAAIC,OAAiD,KAAqB;EACzF,CAACJ,YAAY,GAAGA,YAAY;EAC5B,GAAGI;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CAACgD,KAAK;CAC1C,CAAC;AAEF;AACA,OAAO,MAAMC,iBAAiB,GAAI5C,OAAuC,IAAwB;EAC/F,IAAIA,OAAO,EAAE6C,iBAAiB,KAAK,KAAK,EAAE;IACxC,OAAO7C,OAAO;EAChB,CAAC,MAAM,IAAIA,OAAO,EAAE6C,iBAAiB,KAAKC,SAAS,IAAI,OAAO9C,OAAO,CAAC6C,iBAAiB,KAAK,SAAS,EAAE;IACrG,OAAO7C,OAAO;EAChB;EACA,MAAM+C,KAAK,GAAGC,KAAK,CAACC,eAAe;EACnCD,KAAK,CAACC,eAAe,GAAG,CAAC;EACzB,MAAMC,UAAU,GAAG,IAAIF,KAAK,EAAE;EAC9BA,KAAK,CAACC,eAAe,GAAGF,KAAK;EAC7B,IAAIG,UAAU,CAACC,KAAK,KAAKL,SAAS,EAAE;IAClC,OAAO;MAAE,GAAG9C,OAAO;MAAE6C,iBAAiB,EAAE;IAAK,CAAE;EACjD;EACA,MAAMM,KAAK,GAAGD,UAAU,CAACC,KAAK,CAACC,KAAK,CAAC,IAAI,CAAC;EAC1C,IAAI,CAACD,KAAK,CAAC,CAAC,CAAC,EAAE;IACb,OAAO;MAAE,GAAGnD,OAAO;MAAE6C,iBAAiB,EAAE;IAAK,CAAE;EACjD;EACA,OAAO;IAAE,GAAG7C,OAAO;IAAE6C,iBAAiB,EAAEM,KAAK,CAAC,CAAC,CAAC,CAACE,IAAI;EAAE,CAAE;AAC3D,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- let moduleVersion = "3.1.6";
1
+ let moduleVersion = "3.2.0";
2
2
  export const getCurrentVersion = () => moduleVersion;
3
3
  export const setCurrentVersion = version => {
4
4
  moduleVersion = version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "effect",
3
- "version": "3.1.6",
3
+ "version": "3.2.0",
4
4
  "description": "The missing standard library for TypeScript, for writing production-grade software.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/Array.ts CHANGED
@@ -12,6 +12,7 @@ import type { LazyArg } from "./Function.js"
12
12
  import { dual, identity } from "./Function.js"
13
13
  import type { TypeLambda } from "./HKT.js"
14
14
  import * as readonlyArray from "./internal/array.js"
15
+ import * as doNotation from "./internal/doNotation.js"
15
16
  import * as EffectIterable from "./Iterable.js"
16
17
  import type { Option } from "./Option.js"
17
18
  import * as O from "./Option.js"
@@ -2111,3 +2112,216 @@ export const cartesian: {
2111
2112
  2,
2112
2113
  <A, B>(self: ReadonlyArray<A>, that: ReadonlyArray<B>): Array<[A, B]> => cartesianWith(self, that, (a, b) => [a, b])
2113
2114
  )
2115
+
2116
+ // -------------------------------------------------------------------------------------
2117
+ // do notation
2118
+ // -------------------------------------------------------------------------------------
2119
+
2120
+ /**
2121
+ * The "do simulation" for array allows you to sequentially apply operations to the elements of arrays, just as nested loops allow you to go through all combinations of elements in an arrays.
2122
+ *
2123
+ * It can be used to simulate "array comprehension".
2124
+ * It's a technique that allows you to create new arrays by iterating over existing ones and applying specific **conditions** or **transformations** to the elements. It's like assembling a new collection from pieces of other collections based on certain rules.
2125
+ *
2126
+ * Here's how the do simulation works:
2127
+ *
2128
+ * 1. Start the do simulation using the `Do` value
2129
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Array` values
2130
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
2131
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
2132
+ * 5. Regular `Option` functions like `map` and `filter` can still be used within the do simulation. These functions will receive the accumulated variables as arguments within the scope
2133
+ *
2134
+ * @see {@link bindTo}
2135
+ * @see {@link bind}
2136
+ * @see {@link let_ let}
2137
+ *
2138
+ * @example
2139
+ * import { Array as Arr, pipe } from "effect"
2140
+ * const doResult = pipe(
2141
+ * Arr.Do,
2142
+ * Arr.bind("x", () => [1, 3, 5]),
2143
+ * Arr.bind("y", () => [2, 4, 6]),
2144
+ * Arr.filter(({ x, y }) => x < y), // condition
2145
+ * Arr.map(({ x, y }) => [x, y] as const) // transformation
2146
+ * )
2147
+ * assert.deepStrictEqual(doResult, [[1, 2], [1, 4], [1, 6], [3, 4], [3, 6], [5, 6]])
2148
+ *
2149
+ * // equivalent
2150
+ * const x = [1, 3, 5],
2151
+ * y = [2, 4, 6],
2152
+ * result = [];
2153
+ * for(let i = 0; i < x.length; i++) {
2154
+ * for(let j = 0; j < y.length; j++) {
2155
+ * const _x = x[i], _y = y[j];
2156
+ * if(_x < _y) result.push([_x, _y] as const)
2157
+ * }
2158
+ * }
2159
+ *
2160
+ * @category do notation
2161
+ * @since 3.2.0
2162
+ */
2163
+ export const Do: ReadonlyArray<{}> = of({})
2164
+
2165
+ /**
2166
+ * The "do simulation" for array allows you to sequentially apply operations to the elements of arrays, just as nested loops allow you to go through all combinations of elements in an arrays.
2167
+ *
2168
+ * It can be used to simulate "array comprehension".
2169
+ * It's a technique that allows you to create new arrays by iterating over existing ones and applying specific **conditions** or **transformations** to the elements. It's like assembling a new collection from pieces of other collections based on certain rules.
2170
+ *
2171
+ * Here's how the do simulation works:
2172
+ *
2173
+ * 1. Start the do simulation using the `Do` value
2174
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Array` values
2175
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
2176
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
2177
+ * 5. Regular `Option` functions like `map` and `filter` can still be used within the do simulation. These functions will receive the accumulated variables as arguments within the scope
2178
+ *
2179
+ * @see {@link bindTo}
2180
+ * @see {@link Do}
2181
+ * @see {@link let_ let}
2182
+ *
2183
+ * @example
2184
+ * import { Array as Arr, pipe } from "effect"
2185
+ * const doResult = pipe(
2186
+ * Arr.Do,
2187
+ * Arr.bind("x", () => [1, 3, 5]),
2188
+ * Arr.bind("y", () => [2, 4, 6]),
2189
+ * Arr.filter(({ x, y }) => x < y), // condition
2190
+ * Arr.map(({ x, y }) => [x, y] as const) // transformation
2191
+ * )
2192
+ * assert.deepStrictEqual(doResult, [[1, 2], [1, 4], [1, 6], [3, 4], [3, 6], [5, 6]])
2193
+ *
2194
+ * // equivalent
2195
+ * const x = [1, 3, 5],
2196
+ * y = [2, 4, 6],
2197
+ * result = [];
2198
+ * for(let i = 0; i < x.length; i++) {
2199
+ * for(let j = 0; j < y.length; j++) {
2200
+ * const _x = x[i], _y = y[j];
2201
+ * if(_x < _y) result.push([_x, _y] as const)
2202
+ * }
2203
+ * }
2204
+ *
2205
+ * @category do notation
2206
+ * @since 3.2.0
2207
+ */
2208
+ export const bind: {
2209
+ <A extends object, N extends string, B>(
2210
+ tag: Exclude<N, keyof A>,
2211
+ f: (a: A) => ReadonlyArray<B>
2212
+ ): (
2213
+ self: ReadonlyArray<A>
2214
+ ) => Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>
2215
+ <A extends object, N extends string, B>(
2216
+ self: ReadonlyArray<A>,
2217
+ tag: Exclude<N, keyof A>,
2218
+ f: (a: A) => ReadonlyArray<B>
2219
+ ): Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>
2220
+ } = doNotation.bind<ReadonlyArrayTypeLambda>(map, flatMap) as any
2221
+
2222
+ /**
2223
+ * The "do simulation" for array allows you to sequentially apply operations to the elements of arrays, just as nested loops allow you to go through all combinations of elements in an arrays.
2224
+ *
2225
+ * It can be used to simulate "array comprehension".
2226
+ * It's a technique that allows you to create new arrays by iterating over existing ones and applying specific **conditions** or **transformations** to the elements. It's like assembling a new collection from pieces of other collections based on certain rules.
2227
+ *
2228
+ * Here's how the do simulation works:
2229
+ *
2230
+ * 1. Start the do simulation using the `Do` value
2231
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Array` values
2232
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
2233
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
2234
+ * 5. Regular `Option` functions like `map` and `filter` can still be used within the do simulation. These functions will receive the accumulated variables as arguments within the scope
2235
+ *
2236
+ * @see {@link bindTo}
2237
+ * @see {@link Do}
2238
+ * @see {@link let_ let}
2239
+ *
2240
+ * @example
2241
+ * import { Array as Arr, pipe } from "effect"
2242
+ * const doResult = pipe(
2243
+ * Arr.Do,
2244
+ * Arr.bind("x", () => [1, 3, 5]),
2245
+ * Arr.bind("y", () => [2, 4, 6]),
2246
+ * Arr.filter(({ x, y }) => x < y), // condition
2247
+ * Arr.map(({ x, y }) => [x, y] as const) // transformation
2248
+ * )
2249
+ * assert.deepStrictEqual(doResult, [[1, 2], [1, 4], [1, 6], [3, 4], [3, 6], [5, 6]])
2250
+ *
2251
+ * // equivalent
2252
+ * const x = [1, 3, 5],
2253
+ * y = [2, 4, 6],
2254
+ * result = [];
2255
+ * for(let i = 0; i < x.length; i++) {
2256
+ * for(let j = 0; j < y.length; j++) {
2257
+ * const _x = x[i], _y = y[j];
2258
+ * if(_x < _y) result.push([_x, _y] as const)
2259
+ * }
2260
+ * }
2261
+ *
2262
+ * @category do notation
2263
+ * @since 3.2.0
2264
+ */
2265
+ export const bindTo: {
2266
+ <N extends string>(tag: N): <A>(self: ReadonlyArray<A>) => Array<{ [K in N]: A }>
2267
+ <A, N extends string>(self: ReadonlyArray<A>, tag: N): Array<{ [K in N]: A }>
2268
+ } = doNotation.bindTo<ReadonlyArrayTypeLambda>(map) as any
2269
+
2270
+ const let_: {
2271
+ <N extends string, B, A extends object>(
2272
+ tag: Exclude<N, keyof A>,
2273
+ f: (a: A) => B
2274
+ ): (self: ReadonlyArray<A>) => Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>
2275
+ <N extends string, A extends object, B>(
2276
+ self: ReadonlyArray<A>,
2277
+ tag: Exclude<N, keyof A>,
2278
+ f: (a: A) => B
2279
+ ): Array<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }>
2280
+ } = doNotation.let_<ReadonlyArrayTypeLambda>(map) as any
2281
+
2282
+ export {
2283
+ /**
2284
+ * The "do simulation" for array allows you to sequentially apply operations to the elements of arrays, just as nested loops allow you to go through all combinations of elements in an arrays.
2285
+ *
2286
+ * It can be used to simulate "array comprehension".
2287
+ * It's a technique that allows you to create new arrays by iterating over existing ones and applying specific **conditions** or **transformations** to the elements. It's like assembling a new collection from pieces of other collections based on certain rules.
2288
+ *
2289
+ * Here's how the do simulation works:
2290
+ *
2291
+ * 1. Start the do simulation using the `Do` value
2292
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Array` values
2293
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
2294
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
2295
+ * 5. Regular `Option` functions like `map` and `filter` can still be used within the do simulation. These functions will receive the accumulated variables as arguments within the scope
2296
+ *
2297
+ * @see {@link bindTo}
2298
+ * @see {@link bind}
2299
+ * @see {@link Do}
2300
+ *
2301
+ * @example
2302
+ * import { Array as Arr, pipe } from "effect"
2303
+ * const doResult = pipe(
2304
+ * Arr.Do,
2305
+ * Arr.bind("x", () => [1, 3, 5]),
2306
+ * Arr.bind("y", () => [2, 4, 6]),
2307
+ * Arr.filter(({ x, y }) => x < y), // condition
2308
+ * Arr.map(({ x, y }) => [x, y] as const) // transformation
2309
+ * )
2310
+ * assert.deepStrictEqual(doResult, [[1, 2], [1, 4], [1, 6], [3, 4], [3, 6], [5, 6]])
2311
+ *
2312
+ * // equivalent
2313
+ * const x = [1, 3, 5],
2314
+ * y = [2, 4, 6],
2315
+ * result = [];
2316
+ * for(let i = 0; i < x.length; i++) {
2317
+ * for(let j = 0; j < y.length; j++) {
2318
+ * const _x = x[i], _y = y[j];
2319
+ * if(_x < _y) result.push([_x, _y] as const)
2320
+ * }
2321
+ * }
2322
+ *
2323
+ * @category do notation
2324
+ * @since 3.2.0
2325
+ */
2326
+ let_ as let
2327
+ }
package/src/Cause.ts CHANGED
@@ -36,6 +36,7 @@ import type { Pipeable } from "./Pipeable.js"
36
36
  import type { Predicate, Refinement } from "./Predicate.js"
37
37
  import type * as Sink from "./Sink.js"
38
38
  import type * as Stream from "./Stream.js"
39
+ import type { Span } from "./Tracer.js"
39
40
  import type { Covariant, NoInfer } from "./Types.js"
40
41
 
41
42
  /**
@@ -914,6 +915,22 @@ export const isUnknownException: (u: unknown) => u is UnknownException = core.is
914
915
  */
915
916
  export const pretty: <E>(cause: Cause<E>) => string = internal.pretty
916
917
 
918
+ /**
919
+ * @since 3.2.0
920
+ * @category models
921
+ */
922
+ export interface PrettyError extends Error {
923
+ readonly span: Span | undefined
924
+ }
925
+
926
+ /**
927
+ * Returns the specified `Cause` as a pretty-printed string.
928
+ *
929
+ * @since 3.2.0
930
+ * @category rendering
931
+ */
932
+ export const prettyErrors: <E>(cause: Cause<E>) => Array<PrettyError> = internal.prettyErrors
933
+
917
934
  /**
918
935
  * Returns the original, unproxied, instance of a thrown error
919
936
  *
package/src/Chunk.ts CHANGED
@@ -1387,3 +1387,33 @@ export const reduceRight: {
1387
1387
  <B, A>(b: B, f: (b: B, a: A, i: number) => B): (self: Chunk<A>) => B
1388
1388
  <A, B>(self: Chunk<A>, b: B, f: (b: B, a: A, i: number) => B): B
1389
1389
  } = RA.reduceRight
1390
+
1391
+ /**
1392
+ * Creates a `Chunk` of values not included in the other given `Chunk` using the provided `isEquivalent` function.
1393
+ * The order and references of result values are determined by the first `Chunk`.
1394
+ *
1395
+ * @since 3.2.0
1396
+ */
1397
+ export const differenceWith = <A>(isEquivalent: (self: A, that: A) => boolean): {
1398
+ (that: Chunk<A>): (self: Chunk<A>) => Chunk<A>
1399
+ (self: Chunk<A>, that: Chunk<A>): Chunk<A>
1400
+ } => {
1401
+ return dual(
1402
+ 2,
1403
+ (self: Chunk<A>, that: Chunk<A>): Chunk<A> => unsafeFromArray(RA.differenceWith(isEquivalent)(that, self))
1404
+ )
1405
+ }
1406
+
1407
+ /**
1408
+ * Creates a `Chunk` of values not included in the other given `Chunk`.
1409
+ * The order and references of result values are determined by the first `Chunk`.
1410
+ *
1411
+ * @since 3.2.0
1412
+ */
1413
+ export const difference: {
1414
+ <A>(that: Chunk<A>): (self: Chunk<A>) => Chunk<A>
1415
+ <A>(self: Chunk<A>, that: Chunk<A>): Chunk<A>
1416
+ } = dual(
1417
+ 2,
1418
+ <A>(self: Chunk<A>, that: Chunk<A>): Chunk<A> => unsafeFromArray(RA.difference(that, self))
1419
+ )
package/src/Data.ts CHANGED
@@ -7,6 +7,7 @@ import * as internal from "./internal/data.js"
7
7
  import { StructuralPrototype } from "./internal/effectable.js"
8
8
  import * as Predicate from "./Predicate.js"
9
9
  import type * as Types from "./Types.js"
10
+ import type { Unify } from "./Unify.js"
10
11
 
11
12
  /**
12
13
  * @since 2.0.0
@@ -336,13 +337,63 @@ export declare namespace TaggedEnum {
336
337
  }
337
338
  & {
338
339
  readonly $is: <Tag extends A["_tag"]>(tag: Tag) => (u: unknown) => u is Extract<A, { readonly _tag: Tag }>
339
- readonly $match: <
340
+ readonly $match: {
341
+ <
342
+ Cases extends {
343
+ readonly [Tag in A["_tag"]]: (args: Extract<A, { readonly _tag: Tag }>) => any
344
+ }
345
+ >(cases: Cases): (value: A) => Unify<ReturnType<Cases[A["_tag"]]>>
346
+ <
347
+ Cases extends {
348
+ readonly [Tag in A["_tag"]]: (args: Extract<A, { readonly _tag: Tag }>) => any
349
+ }
350
+ >(value: A, cases: Cases): Unify<ReturnType<Cases[A["_tag"]]>>
351
+ }
352
+ }
353
+ >
354
+
355
+ /**
356
+ * @since 3.2.0
357
+ */
358
+ export interface GenericMatchers<Z extends WithGenerics<number>> {
359
+ readonly $is: <Tag extends Z["taggedEnum"]["_tag"]>(
360
+ tag: Tag
361
+ ) => {
362
+ <T extends TaggedEnum.Kind<Z, any, any, any, any>>(
363
+ u: T
364
+ ): u is T & { readonly _tag: Tag }
365
+ (u: unknown): u is Extract<TaggedEnum.Kind<Z>, { readonly _tag: Tag }>
366
+ }
367
+ readonly $match: {
368
+ <
369
+ A,
370
+ B,
371
+ C,
372
+ D,
373
+ Cases extends {
374
+ readonly [Tag in Z["taggedEnum"]["_tag"]]: (
375
+ args: Extract<TaggedEnum.Kind<Z, A, B, C, D>, { readonly _tag: Tag }>
376
+ ) => any
377
+ }
378
+ >(
379
+ cases: Cases
380
+ ): (self: TaggedEnum.Kind<Z, A, B, C, D>) => Unify<ReturnType<Cases[Z["taggedEnum"]["_tag"]]>>
381
+ <
382
+ A,
383
+ B,
384
+ C,
385
+ D,
340
386
  Cases extends {
341
- readonly [Tag in A["_tag"]]: (args: Extract<A, { readonly _tag: Tag }>) => any
387
+ readonly [Tag in Z["taggedEnum"]["_tag"]]: (
388
+ args: Extract<TaggedEnum.Kind<Z, A, B, C, D>, { readonly _tag: Tag }>
389
+ ) => any
342
390
  }
343
- >(cases: Cases) => (value: A) => ReturnType<Cases[A["_tag"]]>
391
+ >(
392
+ self: TaggedEnum.Kind<Z, A, B, C, D>,
393
+ cases: Cases
394
+ ): Unify<ReturnType<Cases[Z["taggedEnum"]["_tag"]]>>
344
395
  }
345
- >
396
+ }
346
397
  }
347
398
 
348
399
  /**
@@ -379,52 +430,60 @@ export declare namespace TaggedEnum {
379
430
  * @since 2.0.0
380
431
  */
381
432
  export const taggedEnum: {
382
- <Z extends TaggedEnum.WithGenerics<1>>(): {
383
- readonly [Tag in Z["taggedEnum"]["_tag"]]: <A>(
384
- args: TaggedEnum.Args<
385
- TaggedEnum.Kind<Z, A>,
386
- Tag,
387
- Extract<TaggedEnum.Kind<Z, A>, { readonly _tag: Tag }>
388
- >
389
- ) => TaggedEnum.Value<TaggedEnum.Kind<Z, A>, Tag>
390
- }
433
+ <Z extends TaggedEnum.WithGenerics<1>>(): Types.Simplify<
434
+ {
435
+ readonly [Tag in Z["taggedEnum"]["_tag"]]: <A>(
436
+ args: TaggedEnum.Args<
437
+ TaggedEnum.Kind<Z, A>,
438
+ Tag,
439
+ Extract<TaggedEnum.Kind<Z, A>, { readonly _tag: Tag }>
440
+ >
441
+ ) => TaggedEnum.Value<TaggedEnum.Kind<Z, A>, Tag>
442
+ } & TaggedEnum.GenericMatchers<Z>
443
+ >
391
444
 
392
- <Z extends TaggedEnum.WithGenerics<2>>(): {
393
- readonly [Tag in Z["taggedEnum"]["_tag"]]: <A, B>(
394
- args: TaggedEnum.Args<
395
- TaggedEnum.Kind<Z, A, B>,
396
- Tag,
397
- Extract<TaggedEnum.Kind<Z, A, B>, { readonly _tag: Tag }>
398
- >
399
- ) => TaggedEnum.Value<TaggedEnum.Kind<Z, A, B>, Tag>
400
- }
445
+ <Z extends TaggedEnum.WithGenerics<2>>(): Types.Simplify<
446
+ {
447
+ readonly [Tag in Z["taggedEnum"]["_tag"]]: <A, B>(
448
+ args: TaggedEnum.Args<
449
+ TaggedEnum.Kind<Z, A, B>,
450
+ Tag,
451
+ Extract<TaggedEnum.Kind<Z, A, B>, { readonly _tag: Tag }>
452
+ >
453
+ ) => TaggedEnum.Value<TaggedEnum.Kind<Z, A, B>, Tag>
454
+ } & TaggedEnum.GenericMatchers<Z>
455
+ >
401
456
 
402
- <Z extends TaggedEnum.WithGenerics<3>>(): {
403
- readonly [Tag in Z["taggedEnum"]["_tag"]]: <A, B, C>(
404
- args: TaggedEnum.Args<
405
- TaggedEnum.Kind<Z, A, B, C>,
406
- Tag,
407
- Extract<TaggedEnum.Kind<Z, A, B, C>, { readonly _tag: Tag }>
408
- >
409
- ) => TaggedEnum.Value<TaggedEnum.Kind<Z, A, B, C>, Tag>
410
- }
457
+ <Z extends TaggedEnum.WithGenerics<3>>(): Types.Simplify<
458
+ {
459
+ readonly [Tag in Z["taggedEnum"]["_tag"]]: <A, B, C>(
460
+ args: TaggedEnum.Args<
461
+ TaggedEnum.Kind<Z, A, B, C>,
462
+ Tag,
463
+ Extract<TaggedEnum.Kind<Z, A, B, C>, { readonly _tag: Tag }>
464
+ >
465
+ ) => TaggedEnum.Value<TaggedEnum.Kind<Z, A, B, C>, Tag>
466
+ } & TaggedEnum.GenericMatchers<Z>
467
+ >
411
468
 
412
- <Z extends TaggedEnum.WithGenerics<4>>(): {
413
- readonly [Tag in Z["taggedEnum"]["_tag"]]: <A, B, C, D>(
414
- args: TaggedEnum.Args<
415
- TaggedEnum.Kind<Z, A, B, C, D>,
416
- Tag,
417
- Extract<TaggedEnum.Kind<Z, A, B, C, D>, { readonly _tag: Tag }>
418
- >
419
- ) => TaggedEnum.Value<TaggedEnum.Kind<Z, A, B, C, D>, Tag>
420
- }
469
+ <Z extends TaggedEnum.WithGenerics<4>>(): Types.Simplify<
470
+ {
471
+ readonly [Tag in Z["taggedEnum"]["_tag"]]: <A, B, C, D>(
472
+ args: TaggedEnum.Args<
473
+ TaggedEnum.Kind<Z, A, B, C, D>,
474
+ Tag,
475
+ Extract<TaggedEnum.Kind<Z, A, B, C, D>, { readonly _tag: Tag }>
476
+ >
477
+ ) => TaggedEnum.Value<TaggedEnum.Kind<Z, A, B, C, D>, Tag>
478
+ } & TaggedEnum.GenericMatchers<Z>
479
+ >
421
480
 
422
481
  <A extends { readonly _tag: string }>(): TaggedEnum.Constructor<A>
423
482
  } = () =>
424
483
  new Proxy({}, {
425
484
  get(_target, tag, _receiver) {
426
485
  if (tag === "$is") {
427
- return taggedIs
486
+ return Predicate.isTagged
428
487
  } else if (tag === "$match") {
429
488
  return taggedMatch
430
489
  }
@@ -432,19 +491,33 @@ export const taggedEnum: {
432
491
  }
433
492
  }) as any
434
493
 
435
- function taggedIs<A extends { readonly _tag: string }, Tag extends A["_tag"]>(tag: Tag) {
436
- return Predicate.isTagged(tag)
437
- }
438
-
439
494
  function taggedMatch<
440
495
  A extends { readonly _tag: string },
441
496
  Cases extends {
442
497
  readonly [K in A["_tag"]]: (args: Extract<A, { readonly _tag: K }>) => any
443
498
  }
444
- >(cases: Cases) {
445
- return function(value: A): ReturnType<Cases[A["_tag"]]> {
446
- return cases[value._tag as A["_tag"]](value as any)
499
+ >(self: A, cases: Cases): ReturnType<Cases[A["_tag"]]>
500
+ function taggedMatch<
501
+ A extends { readonly _tag: string },
502
+ Cases extends {
503
+ readonly [K in A["_tag"]]: (args: Extract<A, { readonly _tag: K }>) => any
504
+ }
505
+ >(cases: Cases): (value: A) => ReturnType<Cases[A["_tag"]]>
506
+ function taggedMatch<
507
+ A extends { readonly _tag: string },
508
+ Cases extends {
509
+ readonly [K in A["_tag"]]: (args: Extract<A, { readonly _tag: K }>) => any
510
+ }
511
+ >(): any {
512
+ if (arguments.length === 1) {
513
+ const cases = arguments[0] as Cases
514
+ return function(value: A): ReturnType<Cases[A["_tag"]]> {
515
+ return cases[value._tag as A["_tag"]](value as any)
516
+ }
447
517
  }
518
+ const value = arguments[0] as A
519
+ const cases = arguments[1] as Cases
520
+ return cases[value._tag as A["_tag"]](value as any)
448
521
  }
449
522
 
450
523
  /**
package/src/Effect.ts CHANGED
@@ -5435,6 +5435,46 @@ export const withSpan: {
5435
5435
  ): Effect<A, E, Exclude<R, Tracer.ParentSpan>>
5436
5436
  } = effect.withSpan
5437
5437
 
5438
+ /**
5439
+ * Wraps a function that returns an effect with a new span for tracing.
5440
+ *
5441
+ * @since 3.2.0
5442
+ * @category models
5443
+ */
5444
+ export interface FunctionWithSpanOptions {
5445
+ readonly name: string
5446
+ readonly attributes?: Record<string, unknown> | undefined
5447
+ readonly links?: ReadonlyArray<Tracer.SpanLink> | undefined
5448
+ readonly parent?: Tracer.AnySpan | undefined
5449
+ readonly root?: boolean | undefined
5450
+ readonly context?: Context.Context<never> | undefined
5451
+ readonly kind?: Tracer.SpanKind | undefined
5452
+ }
5453
+
5454
+ /**
5455
+ * Wraps a function that returns an effect with a new span for tracing.
5456
+ *
5457
+ * @since 3.2.0
5458
+ * @category tracing
5459
+ * @example
5460
+ * import { Effect } from "effect"
5461
+ *
5462
+ * const getTodo = Effect.functionWithSpan({
5463
+ * body: (id: number) => Effect.succeed(`Got todo ${id}!`),
5464
+ * options: (id) => ({
5465
+ * name: `getTodo-${id}`,
5466
+ * attributes: { id }
5467
+ * })
5468
+ * })
5469
+ */
5470
+ export const functionWithSpan: <Args extends Array<any>, Ret extends Effect<any, any, any>>(
5471
+ options: {
5472
+ readonly body: (...args: Args) => Ret
5473
+ readonly options: FunctionWithSpanOptions | ((...args: Args) => FunctionWithSpanOptions)
5474
+ readonly captureStackTrace?: boolean | undefined
5475
+ }
5476
+ ) => (...args: Args) => Unify.Unify<Ret> = effect.functionWithSpan
5477
+
5438
5478
  /**
5439
5479
  * Wraps the effect with a new span for tracing.
5440
5480
  *
package/src/Stream.ts CHANGED
@@ -22,6 +22,7 @@ import type { Pipeable } from "./Pipeable.js"
22
22
  import type { Predicate, Refinement } from "./Predicate.js"
23
23
  import type * as PubSub from "./PubSub.js"
24
24
  import type * as Queue from "./Queue.js"
25
+ import type { Runtime } from "./Runtime.js"
25
26
  import type * as Schedule from "./Schedule.js"
26
27
  import type * as Scope from "./Scope.js"
27
28
  import type * as Sink from "./Sink.js"
@@ -3859,7 +3860,36 @@ export const toQueueOfElements: {
3859
3860
  * @since 2.0.0
3860
3861
  * @category destructors
3861
3862
  */
3862
- export const toReadableStream: <A, E>(source: Stream<A, E>) => ReadableStream<A> = internal.toReadableStream
3863
+ export const toReadableStream: <A, E>(self: Stream<A, E>) => ReadableStream<A> = internal.toReadableStream
3864
+
3865
+ /**
3866
+ * Converts the stream to a `Effect<ReadableStream>`.
3867
+ *
3868
+ * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream.
3869
+ *
3870
+ * @since 2.0.0
3871
+ * @category destructors
3872
+ */
3873
+ export const toReadableStreamEffect: <A, E, R>(self: Stream<A, E, R>) => Effect.Effect<ReadableStream<A>, never, R> =
3874
+ internal.toReadableStreamEffect
3875
+
3876
+ /**
3877
+ * Converts the stream to a `ReadableStream` using the provided runtime.
3878
+ *
3879
+ * See https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream.
3880
+ *
3881
+ * @since 2.0.0
3882
+ * @category destructors
3883
+ */
3884
+ export const toReadableStreamRuntime: {
3885
+ <XR>(
3886
+ runtime: Runtime<XR>
3887
+ ): <A, E, R extends XR>(self: Stream<A, E, R>) => ReadableStream<A>
3888
+ <A, E, XR, R extends XR>(
3889
+ self: Stream<A, E, R>,
3890
+ runtime: Runtime<XR>
3891
+ ): ReadableStream<A>
3892
+ } = internal.toReadableStreamRuntime
3863
3893
 
3864
3894
  /**
3865
3895
  * Applies the transducer to the stream and emits its outputs.