effect 3.1.0 → 3.1.2

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 (278) hide show
  1. package/dist/cjs/Array.js +10 -13
  2. package/dist/cjs/Array.js.map +1 -1
  3. package/dist/cjs/BigDecimal.js +14 -17
  4. package/dist/cjs/BigDecimal.js.map +1 -1
  5. package/dist/cjs/BigInt.js +41 -46
  6. package/dist/cjs/BigInt.js.map +1 -1
  7. package/dist/cjs/Boolean.js +13 -13
  8. package/dist/cjs/Brand.js +2 -2
  9. package/dist/cjs/Chunk.js +3 -3
  10. package/dist/cjs/Context.js +15 -20
  11. package/dist/cjs/Context.js.map +1 -1
  12. package/dist/cjs/Cron.js +3 -6
  13. package/dist/cjs/Cron.js.map +1 -1
  14. package/dist/cjs/Data.js +8 -13
  15. package/dist/cjs/Data.js.map +1 -1
  16. package/dist/cjs/Duration.js +1 -1
  17. package/dist/cjs/Effect.js +77 -9
  18. package/dist/cjs/Effect.js.map +1 -1
  19. package/dist/cjs/Either.js +117 -59
  20. package/dist/cjs/Either.js.map +1 -1
  21. package/dist/cjs/Equal.js +26 -4
  22. package/dist/cjs/Equal.js.map +1 -1
  23. package/dist/cjs/FiberHandle.js.map +1 -1
  24. package/dist/cjs/FiberMap.js.map +1 -1
  25. package/dist/cjs/FiberSet.js.map +1 -1
  26. package/dist/cjs/Function.js +2 -2
  27. package/dist/cjs/Function.js.map +1 -1
  28. package/dist/cjs/Hash.js +29 -12
  29. package/dist/cjs/Hash.js.map +1 -1
  30. package/dist/cjs/Iterable.js +10 -13
  31. package/dist/cjs/Iterable.js.map +1 -1
  32. package/dist/cjs/List.js +2 -2
  33. package/dist/cjs/Metric.js +5 -7
  34. package/dist/cjs/Metric.js.map +1 -1
  35. package/dist/cjs/Number.js +20 -21
  36. package/dist/cjs/Number.js.map +1 -1
  37. package/dist/cjs/Option.js +223 -164
  38. package/dist/cjs/Option.js.map +1 -1
  39. package/dist/cjs/Order.js +1 -2
  40. package/dist/cjs/Order.js.map +1 -1
  41. package/dist/cjs/Ordering.js +2 -2
  42. package/dist/cjs/Predicate.js +9 -12
  43. package/dist/cjs/Predicate.js.map +1 -1
  44. package/dist/cjs/Readable.js.map +1 -1
  45. package/dist/cjs/Record.js +35 -47
  46. package/dist/cjs/Record.js.map +1 -1
  47. package/dist/cjs/RegExp.js +1 -1
  48. package/dist/cjs/Request.js +2 -2
  49. package/dist/cjs/Request.js.map +1 -1
  50. package/dist/cjs/Stream.js +82 -4
  51. package/dist/cjs/Stream.js.map +1 -1
  52. package/dist/cjs/String.js +81 -111
  53. package/dist/cjs/String.js.map +1 -1
  54. package/dist/cjs/Struct.js +13 -19
  55. package/dist/cjs/Struct.js.map +1 -1
  56. package/dist/cjs/Subscribable.js.map +1 -1
  57. package/dist/cjs/Symbol.js +3 -3
  58. package/dist/cjs/TestAnnotation.js.map +1 -1
  59. package/dist/cjs/TestAnnotationMap.js.map +1 -1
  60. package/dist/cjs/TestAnnotations.js.map +1 -1
  61. package/dist/cjs/TestClock.js.map +1 -1
  62. package/dist/cjs/TestLive.js.map +1 -1
  63. package/dist/cjs/TestSized.js.map +1 -1
  64. package/dist/cjs/Trie.js +28 -44
  65. package/dist/cjs/Trie.js.map +1 -1
  66. package/dist/cjs/Utils.js +35 -1
  67. package/dist/cjs/Utils.js.map +1 -1
  68. package/dist/cjs/internal/core-effect.js +4 -11
  69. package/dist/cjs/internal/core-effect.js.map +1 -1
  70. package/dist/cjs/internal/core.js +16 -4
  71. package/dist/cjs/internal/core.js.map +1 -1
  72. package/dist/cjs/internal/doNotation.js +23 -0
  73. package/dist/cjs/internal/doNotation.js.map +1 -0
  74. package/dist/cjs/internal/groupBy.js.map +1 -1
  75. package/dist/cjs/internal/stream.js +3 -7
  76. package/dist/cjs/internal/stream.js.map +1 -1
  77. package/dist/cjs/internal/version.js +1 -1
  78. package/dist/dts/Array.d.ts +10 -13
  79. package/dist/dts/Array.d.ts.map +1 -1
  80. package/dist/dts/BigDecimal.d.ts +14 -17
  81. package/dist/dts/BigDecimal.d.ts.map +1 -1
  82. package/dist/dts/BigInt.d.ts +41 -46
  83. package/dist/dts/BigInt.d.ts.map +1 -1
  84. package/dist/dts/Boolean.d.ts +13 -13
  85. package/dist/dts/Brand.d.ts +3 -3
  86. package/dist/dts/Chunk.d.ts +3 -3
  87. package/dist/dts/Context.d.ts +15 -20
  88. package/dist/dts/Context.d.ts.map +1 -1
  89. package/dist/dts/Cron.d.ts +3 -6
  90. package/dist/dts/Cron.d.ts.map +1 -1
  91. package/dist/dts/Data.d.ts +10 -16
  92. package/dist/dts/Data.d.ts.map +1 -1
  93. package/dist/dts/Duration.d.ts +1 -1
  94. package/dist/dts/Effect.d.ts +120 -26
  95. package/dist/dts/Effect.d.ts.map +1 -1
  96. package/dist/dts/Either.d.ts +155 -64
  97. package/dist/dts/Either.d.ts.map +1 -1
  98. package/dist/dts/Equal.d.ts.map +1 -1
  99. package/dist/dts/FiberHandle.d.ts.map +1 -1
  100. package/dist/dts/FiberMap.d.ts.map +1 -1
  101. package/dist/dts/FiberSet.d.ts.map +1 -1
  102. package/dist/dts/Function.d.ts +4 -2
  103. package/dist/dts/Function.d.ts.map +1 -1
  104. package/dist/dts/Hash.d.ts.map +1 -1
  105. package/dist/dts/HashMap.d.ts +2 -2
  106. package/dist/dts/Iterable.d.ts +10 -13
  107. package/dist/dts/Iterable.d.ts.map +1 -1
  108. package/dist/dts/List.d.ts +2 -2
  109. package/dist/dts/Metric.d.ts +5 -7
  110. package/dist/dts/Metric.d.ts.map +1 -1
  111. package/dist/dts/Number.d.ts +20 -21
  112. package/dist/dts/Number.d.ts.map +1 -1
  113. package/dist/dts/Option.d.ts +245 -155
  114. package/dist/dts/Option.d.ts.map +1 -1
  115. package/dist/dts/Order.d.ts +1 -2
  116. package/dist/dts/Order.d.ts.map +1 -1
  117. package/dist/dts/Ordering.d.ts +2 -2
  118. package/dist/dts/Predicate.d.ts +9 -12
  119. package/dist/dts/Predicate.d.ts.map +1 -1
  120. package/dist/dts/Readable.d.ts.map +1 -1
  121. package/dist/dts/Record.d.ts +35 -47
  122. package/dist/dts/Record.d.ts.map +1 -1
  123. package/dist/dts/RegExp.d.ts +1 -1
  124. package/dist/dts/Request.d.ts +2 -2
  125. package/dist/dts/Request.d.ts.map +1 -1
  126. package/dist/dts/Stream.d.ts +136 -31
  127. package/dist/dts/Stream.d.ts.map +1 -1
  128. package/dist/dts/String.d.ts +81 -111
  129. package/dist/dts/String.d.ts.map +1 -1
  130. package/dist/dts/Struct.d.ts +13 -19
  131. package/dist/dts/Struct.d.ts.map +1 -1
  132. package/dist/dts/Subscribable.d.ts.map +1 -1
  133. package/dist/dts/Symbol.d.ts +3 -3
  134. package/dist/dts/TestAnnotation.d.ts.map +1 -1
  135. package/dist/dts/TestAnnotationMap.d.ts.map +1 -1
  136. package/dist/dts/TestAnnotations.d.ts.map +1 -1
  137. package/dist/dts/TestClock.d.ts +1 -5
  138. package/dist/dts/TestClock.d.ts.map +1 -1
  139. package/dist/dts/TestLive.d.ts.map +1 -1
  140. package/dist/dts/TestSized.d.ts.map +1 -1
  141. package/dist/dts/Trie.d.ts +28 -44
  142. package/dist/dts/Trie.d.ts.map +1 -1
  143. package/dist/dts/Types.d.ts +10 -10
  144. package/dist/dts/Utils.d.ts +19 -0
  145. package/dist/dts/Utils.d.ts.map +1 -1
  146. package/dist/dts/internal/core.d.ts.map +1 -1
  147. package/dist/dts/internal/doNotation.d.ts +2 -0
  148. package/dist/dts/internal/doNotation.d.ts.map +1 -0
  149. package/dist/dts/internal/stream.d.ts.map +1 -1
  150. package/dist/esm/Array.js +10 -13
  151. package/dist/esm/Array.js.map +1 -1
  152. package/dist/esm/BigDecimal.js +14 -17
  153. package/dist/esm/BigDecimal.js.map +1 -1
  154. package/dist/esm/BigInt.js +41 -46
  155. package/dist/esm/BigInt.js.map +1 -1
  156. package/dist/esm/Boolean.js +13 -13
  157. package/dist/esm/Brand.js +2 -2
  158. package/dist/esm/Chunk.js +3 -3
  159. package/dist/esm/Context.js +15 -20
  160. package/dist/esm/Context.js.map +1 -1
  161. package/dist/esm/Cron.js +3 -6
  162. package/dist/esm/Cron.js.map +1 -1
  163. package/dist/esm/Data.js +9 -15
  164. package/dist/esm/Data.js.map +1 -1
  165. package/dist/esm/Duration.js +1 -1
  166. package/dist/esm/Effect.js +101 -11
  167. package/dist/esm/Effect.js.map +1 -1
  168. package/dist/esm/Either.js +141 -61
  169. package/dist/esm/Either.js.map +1 -1
  170. package/dist/esm/Equal.js +26 -4
  171. package/dist/esm/Equal.js.map +1 -1
  172. package/dist/esm/FiberHandle.js.map +1 -1
  173. package/dist/esm/FiberMap.js.map +1 -1
  174. package/dist/esm/FiberSet.js.map +1 -1
  175. package/dist/esm/Function.js +2 -2
  176. package/dist/esm/Function.js.map +1 -1
  177. package/dist/esm/Hash.js +30 -13
  178. package/dist/esm/Hash.js.map +1 -1
  179. package/dist/esm/Iterable.js +10 -13
  180. package/dist/esm/Iterable.js.map +1 -1
  181. package/dist/esm/List.js +2 -2
  182. package/dist/esm/Metric.js +5 -7
  183. package/dist/esm/Metric.js.map +1 -1
  184. package/dist/esm/Number.js +20 -21
  185. package/dist/esm/Number.js.map +1 -1
  186. package/dist/esm/Option.js +249 -164
  187. package/dist/esm/Option.js.map +1 -1
  188. package/dist/esm/Order.js +1 -2
  189. package/dist/esm/Order.js.map +1 -1
  190. package/dist/esm/Ordering.js +2 -2
  191. package/dist/esm/Predicate.js +9 -12
  192. package/dist/esm/Predicate.js.map +1 -1
  193. package/dist/esm/Readable.js.map +1 -1
  194. package/dist/esm/Record.js +35 -47
  195. package/dist/esm/Record.js.map +1 -1
  196. package/dist/esm/RegExp.js +1 -1
  197. package/dist/esm/Request.js +2 -2
  198. package/dist/esm/Request.js.map +1 -1
  199. package/dist/esm/Stream.js +107 -6
  200. package/dist/esm/Stream.js.map +1 -1
  201. package/dist/esm/String.js +81 -111
  202. package/dist/esm/String.js.map +1 -1
  203. package/dist/esm/Struct.js +13 -19
  204. package/dist/esm/Struct.js.map +1 -1
  205. package/dist/esm/Subscribable.js.map +1 -1
  206. package/dist/esm/Symbol.js +3 -3
  207. package/dist/esm/TestAnnotation.js.map +1 -1
  208. package/dist/esm/TestAnnotationMap.js.map +1 -1
  209. package/dist/esm/TestAnnotations.js.map +1 -1
  210. package/dist/esm/TestClock.js.map +1 -1
  211. package/dist/esm/TestLive.js.map +1 -1
  212. package/dist/esm/TestSized.js.map +1 -1
  213. package/dist/esm/Trie.js +28 -44
  214. package/dist/esm/Trie.js.map +1 -1
  215. package/dist/esm/Utils.js +33 -0
  216. package/dist/esm/Utils.js.map +1 -1
  217. package/dist/esm/internal/core-effect.js +4 -11
  218. package/dist/esm/internal/core-effect.js.map +1 -1
  219. package/dist/esm/internal/core.js +16 -4
  220. package/dist/esm/internal/core.js.map +1 -1
  221. package/dist/esm/internal/doNotation.js +14 -0
  222. package/dist/esm/internal/doNotation.js.map +1 -0
  223. package/dist/esm/internal/groupBy.js.map +1 -1
  224. package/dist/esm/internal/stream.js +3 -7
  225. package/dist/esm/internal/stream.js.map +1 -1
  226. package/dist/esm/internal/version.js +1 -1
  227. package/package.json +1 -1
  228. package/src/Array.ts +10 -13
  229. package/src/BigDecimal.ts +14 -17
  230. package/src/BigInt.ts +41 -46
  231. package/src/Boolean.ts +13 -13
  232. package/src/Brand.ts +3 -3
  233. package/src/Chunk.ts +3 -3
  234. package/src/Context.ts +15 -20
  235. package/src/Cron.ts +3 -6
  236. package/src/Data.ts +10 -16
  237. package/src/Duration.ts +1 -1
  238. package/src/Effect.ts +122 -32
  239. package/src/Either.ts +161 -94
  240. package/src/Equal.ts +30 -9
  241. package/src/FiberHandle.ts +1 -1
  242. package/src/FiberMap.ts +1 -1
  243. package/src/FiberSet.ts +1 -1
  244. package/src/Function.ts +4 -2
  245. package/src/Hash.ts +30 -13
  246. package/src/HashMap.ts +2 -2
  247. package/src/Iterable.ts +10 -13
  248. package/src/List.ts +2 -2
  249. package/src/Metric.ts +5 -7
  250. package/src/Number.ts +20 -21
  251. package/src/Option.ts +250 -172
  252. package/src/Order.ts +1 -2
  253. package/src/Ordering.ts +2 -2
  254. package/src/Predicate.ts +9 -12
  255. package/src/Readable.ts +1 -1
  256. package/src/Record.ts +35 -47
  257. package/src/RegExp.ts +1 -1
  258. package/src/Request.ts +3 -3
  259. package/src/Stream.ts +137 -36
  260. package/src/String.ts +81 -111
  261. package/src/Struct.ts +13 -19
  262. package/src/Subscribable.ts +1 -1
  263. package/src/Symbol.ts +3 -3
  264. package/src/TestAnnotation.ts +1 -1
  265. package/src/TestAnnotationMap.ts +1 -1
  266. package/src/TestAnnotations.ts +1 -1
  267. package/src/TestClock.ts +1 -5
  268. package/src/TestLive.ts +1 -1
  269. package/src/TestSized.ts +1 -1
  270. package/src/Trie.ts +28 -44
  271. package/src/Types.ts +10 -10
  272. package/src/Utils.ts +40 -2
  273. package/src/internal/core-effect.ts +29 -45
  274. package/src/internal/core.ts +20 -4
  275. package/src/internal/doNotation.ts +77 -0
  276. package/src/internal/groupBy.ts +16 -16
  277. package/src/internal/stream.ts +34 -58
  278. package/src/internal/version.ts +1 -1
package/src/Trie.ts CHANGED
@@ -44,8 +44,7 @@ export interface Trie<in out Value> extends Iterable<[string, Value]>, Equal, Pi
44
44
  * Creates an empty `Trie`.
45
45
  *
46
46
  * @example
47
- * import * as Trie from "effect/Trie"
48
- * import * as Equal from "effect/Equal"
47
+ * import { Trie, Equal } from "effect"
49
48
  *
50
49
  * const trie = Trie.empty<string>()
51
50
  *
@@ -61,8 +60,7 @@ export const empty: <V = never>() => Trie<V> = TR.empty
61
60
  * Creates a new `Trie` from an iterable collection of key/value pairs (e.g. `Array<[string, V]>`).
62
61
  *
63
62
  * @example
64
- * import * as Trie from "effect/Trie"
65
- * import * as Equal from "effect/Equal"
63
+ * import { Trie, Equal } from "effect"
66
64
  *
67
65
  * const iterable: Array<readonly [string, number]> = [["call", 0], ["me", 1], ["mind", 2], ["mid", 3]]
68
66
  * const trie = Trie.fromIterable(iterable)
@@ -80,8 +78,7 @@ export const fromIterable: <V>(entries: Iterable<readonly [string, V]>) => Trie<
80
78
  * Constructs a new `Trie` from the specified entries (`[string, V]`).
81
79
  *
82
80
  * @example
83
- * import * as Trie from "effect/Trie"
84
- * import * as Equal from "effect/Equal"
81
+ * import { Trie, Equal } from "effect"
85
82
  *
86
83
  * const trie = Trie.make(["ca", 0], ["me", 1])
87
84
  *
@@ -99,7 +96,7 @@ export const make: <Entries extends Array<readonly [string, any]>>(
99
96
  * Insert a new entry in the `Trie`.
100
97
  *
101
98
  * @example
102
- * import * as Trie from "effect/Trie"
99
+ * import { Trie } from "effect"
103
100
  *
104
101
  * const trie1 = Trie.empty<number>().pipe(
105
102
  * Trie.insert("call", 0)
@@ -127,7 +124,7 @@ export const insert: {
127
124
  * The keys are returned in alphabetical order, regardless of insertion order.
128
125
  *
129
126
  * @example
130
- * import * as Trie from "effect/Trie"
127
+ * import { Trie } from "effect"
131
128
  *
132
129
  * const trie = Trie.empty<number>().pipe(
133
130
  * Trie.insert("cab", 0),
@@ -149,7 +146,7 @@ export const keys: <V>(self: Trie<V>) => IterableIterator<string> = TR.keys
149
146
  * Values are ordered based on their key in alphabetical order, regardless of insertion order.
150
147
  *
151
148
  * @example
152
- * import * as Trie from "effect/Trie"
149
+ * import { Trie } from "effect"
153
150
  *
154
151
  * const trie = Trie.empty<number>().pipe(
155
152
  * Trie.insert("call", 0),
@@ -171,7 +168,7 @@ export const values: <V>(self: Trie<V>) => IterableIterator<V> = TR.values
171
168
  * The entries are returned by keys in alphabetical order, regardless of insertion order.
172
169
  *
173
170
  * @example
174
- * import * as Trie from "effect/Trie"
171
+ * import { Trie } from "effect"
175
172
  *
176
173
  * const trie = Trie.empty<number>().pipe(
177
174
  * Trie.insert("call", 0),
@@ -192,7 +189,7 @@ export const entries: <V>(self: Trie<V>) => IterableIterator<[string, V]> = TR.e
192
189
  * Equivalent to `Array.from(Trie.entries(trie))`.
193
190
  *
194
191
  * @example
195
- * import * as Trie from "effect/Trie"
192
+ * import { Trie } from "effect"
196
193
  *
197
194
  * const trie = Trie.empty<number>().pipe(
198
195
  * Trie.insert("call", 0),
@@ -212,7 +209,7 @@ export const toEntries = <V>(self: Trie<V>): Array<[string, V]> => Array.from(en
212
209
  * that have `prefix` as prefix (`prefix` included if it exists).
213
210
  *
214
211
  * @example
215
- * import * as Trie from "effect/Trie"
212
+ * import { Trie } from "effect"
216
213
  *
217
214
  * const trie = Trie.empty<number>().pipe(
218
215
  * Trie.insert("she", 0),
@@ -237,7 +234,7 @@ export const keysWithPrefix: {
237
234
  * that have `prefix` as prefix (`prefix` included if it exists).
238
235
  *
239
236
  * @example
240
- * import * as Trie from "effect/Trie"
237
+ * import { Trie } from "effect"
241
238
  *
242
239
  * const trie = Trie.empty<number>().pipe(
243
240
  * Trie.insert("she", 0),
@@ -264,7 +261,7 @@ export const valuesWithPrefix: {
264
261
  * that have `prefix` as prefix (`prefix` included if it exists).
265
262
  *
266
263
  * @example
267
- * import * as Trie from "effect/Trie"
264
+ * import { Trie } from "effect"
268
265
  *
269
266
  * const trie = Trie.empty<number>().pipe(
270
267
  * Trie.insert("she", 0),
@@ -289,7 +286,7 @@ export const entriesWithPrefix: {
289
286
  * that have `prefix` as prefix (`prefix` included if it exists).
290
287
  *
291
288
  * @example
292
- * import * as Trie from "effect/Trie"
289
+ * import { Trie } from "effect"
293
290
  *
294
291
  * const trie = Trie.empty<number>().pipe(
295
292
  * Trie.insert("shells", 0),
@@ -314,8 +311,7 @@ export const toEntriesWithPrefix: {
314
311
  * that is a prefix of that `key` if it exists, `None` otherwise.
315
312
  *
316
313
  * @example
317
- * import * as Trie from "effect/Trie"
318
- * import * as Option from "effect/Option"
314
+ * import { Trie, Option } from "effect"
319
315
  *
320
316
  * const trie = Trie.empty<number>().pipe(
321
317
  * Trie.insert("shells", 0),
@@ -340,7 +336,7 @@ export const longestPrefixOf: {
340
336
  * Returns the size of the `Trie` (number of entries in the `Trie`).
341
337
  *
342
338
  * @example
343
- * import * as Trie from "effect/Trie"
339
+ * import { Trie } from "effect"
344
340
  *
345
341
  * const trie = Trie.empty<number>().pipe(
346
342
  * Trie.insert("a", 0),
@@ -358,8 +354,7 @@ export const size: <V>(self: Trie<V>) => number = TR.size
358
354
  * Safely lookup the value for the specified key in the `Trie`.
359
355
  *
360
356
  * @example
361
- * import * as Trie from "effect/Trie"
362
- * import * as Option from "effect/Option"
357
+ * import { Trie, Option } from "effect"
363
358
  *
364
359
  * const trie = Trie.empty<number>().pipe(
365
360
  * Trie.insert("call", 0),
@@ -389,7 +384,7 @@ export const get: {
389
384
  * Check if the given key exists in the `Trie`.
390
385
  *
391
386
  * @example
392
- * import * as Trie from "effect/Trie"
387
+ * import { Trie } from "effect"
393
388
  *
394
389
  * const trie = Trie.empty<number>().pipe(
395
390
  * Trie.insert("call", 0),
@@ -419,7 +414,7 @@ export const has: {
419
414
  * Checks if the `Trie` contains any entries.
420
415
  *
421
416
  * @example
422
- * import * as Trie from "effect/Trie"
417
+ * import { Trie } from "effect"
423
418
  *
424
419
  * const trie = Trie.empty<number>()
425
420
  * const trie1 = trie.pipe(Trie.insert("ma", 0))
@@ -439,7 +434,7 @@ export const isEmpty: <V>(self: Trie<V>) => boolean = TR.isEmpty
439
434
  * get a value from the `Trie`.
440
435
  *
441
436
  * @example
442
- * import * as Trie from "effect/Trie"
437
+ * import { Trie } from "effect"
443
438
  *
444
439
  * const trie = Trie.empty<number>().pipe(
445
440
  * Trie.insert("call", 0),
@@ -460,8 +455,7 @@ export const unsafeGet: {
460
455
  * Remove the entry for the specified key in the `Trie`.
461
456
  *
462
457
  * @example
463
- * import * as Trie from "effect/Trie"
464
- * import * as Option from "effect/Option"
458
+ * import { Trie, Option } from "effect"
465
459
  *
466
460
  * const trie = Trie.empty<number>().pipe(
467
461
  * Trie.insert("call", 0),
@@ -489,7 +483,7 @@ export const remove: {
489
483
  * Reduce a state over the entries of the `Trie`.
490
484
  *
491
485
  * @example
492
- * import * as Trie from "effect/Trie"
486
+ * import { Trie } from "effect"
493
487
  *
494
488
  * const trie = Trie.empty<number>().pipe(
495
489
  * Trie.insert("shells", 0),
@@ -528,8 +522,7 @@ export const reduce: {
528
522
  * Maps over the entries of the `Trie` using the specified function.
529
523
  *
530
524
  * @example
531
- * import * as Trie from "effect/Trie"
532
- * import * as Equal from "effect/Equal"
525
+ * import { Trie, Equal } from "effect"
533
526
  *
534
527
  * const trie = Trie.empty<number>().pipe(
535
528
  * Trie.insert("shells", 0),
@@ -564,8 +557,7 @@ export const map: {
564
557
  * Filters entries out of a `Trie` using the specified predicate.
565
558
  *
566
559
  * @example
567
- * import * as Trie from "effect/Trie"
568
- * import * as Equal from "effect/Equal"
560
+ * import { Trie, Equal } from "effect"
569
561
  *
570
562
  * const trie = Trie.empty<number>().pipe(
571
563
  * Trie.insert("shells", 0),
@@ -600,9 +592,7 @@ export const filter: {
600
592
  * and filters out `None` values.
601
593
  *
602
594
  * @example
603
- * import * as Trie from "effect/Trie"
604
- * import * as Equal from "effect/Equal"
605
- * import * as Option from "effect/Option"
595
+ * import { Trie, Equal, Option } from "effect"
606
596
  *
607
597
  * const trie = Trie.empty<number>().pipe(
608
598
  * Trie.insert("shells", 0),
@@ -637,9 +627,7 @@ export const filterMap: {
637
627
  * Filters out `None` values from a `Trie` of `Options`s.
638
628
  *
639
629
  * @example
640
- * import * as Trie from "effect/Trie"
641
- * import * as Equal from "effect/Equal"
642
- * import * as Option from "effect/Option"
630
+ * import { Trie, Equal, Option } from "effect"
643
631
  *
644
632
  * const trie = Trie.empty<Option.Option<number>>().pipe(
645
633
  * Trie.insert("shells", Option.some(0)),
@@ -663,7 +651,7 @@ export const compact: <A>(self: Trie<Option<A>>) => Trie<A> = TR.compact
663
651
  * Applies the specified function to the entries of the `Trie`.
664
652
  *
665
653
  * @example
666
- * import * as Trie from "effect/Trie"
654
+ * import { Trie } from "effect"
667
655
  *
668
656
  * let value = 0
669
657
  *
@@ -690,9 +678,7 @@ export const forEach: {
690
678
  * Updates the value of the specified key within the `Trie` if it exists.
691
679
  *
692
680
  * @example
693
- * import * as Trie from "effect/Trie"
694
- * import * as Equal from "effect/Equal"
695
- * import * as Option from "effect/Option"
681
+ * import { Trie, Equal, Option } from "effect"
696
682
  *
697
683
  * const trie = Trie.empty<number>().pipe(
698
684
  * Trie.insert("shells", 0),
@@ -716,8 +702,7 @@ export const modify: {
716
702
  * Removes all entries in the `Trie` which have the specified keys.
717
703
  *
718
704
  * @example
719
- * import * as Trie from "effect/Trie"
720
- * import * as Equal from "effect/Equal"
705
+ * import { Trie, Equal } from "effect"
721
706
  *
722
707
  * const trie = Trie.empty<number>().pipe(
723
708
  * Trie.insert("shells", 0),
@@ -742,8 +727,7 @@ export const removeMany: {
742
727
  * Insert multiple entries in the `Trie` at once.
743
728
  *
744
729
  * @example
745
- * import * as Trie from "effect/Trie"
746
- * import * as Equal from "effect/Equal"
730
+ * import { Trie, Equal } from "effect"
747
731
  *
748
732
  * const trie = Trie.empty<number>().pipe(
749
733
  * Trie.insert("shells", 0),
package/src/Types.ts CHANGED
@@ -7,7 +7,7 @@
7
7
  /**
8
8
  * Returns the tags in a type.
9
9
  * @example
10
- * import * as Types from "effect/Types"
10
+ * import type { Types } from "effect"
11
11
  *
12
12
  * type Res = Types.Tags<string | { _tag: "a" } | { _tag: "b" } > // "a" | "b"
13
13
  *
@@ -19,7 +19,7 @@ export type Tags<E> = E extends { _tag: string } ? E["_tag"] : never
19
19
  /**
20
20
  * Excludes the tagged object from the type.
21
21
  * @example
22
- * import * as Types from "effect/Types"
22
+ * import type { Types } from "effect"
23
23
  *
24
24
  * type Res = Types.ExcludeTag<string | { _tag: "a" } | { _tag: "b" }, "a"> // string | { _tag: "b" }
25
25
  *
@@ -32,7 +32,7 @@ export type ExcludeTag<E, K extends Tags<E>> = Exclude<E, { _tag: K }>
32
32
  * Extracts the type of the given tag.
33
33
  *
34
34
  * @example
35
- * import * as Types from "effect/Types"
35
+ * import type { Types } from "effect"
36
36
  *
37
37
  * type Res = Types.ExtractTag<{ _tag: "a", a: number } | { _tag: "b", b: number }, "b"> // { _tag: "b", b: number }
38
38
  *
@@ -54,7 +54,7 @@ export type UnionToIntersection<T> = (T extends any ? (x: T) => any : never) ext
54
54
  * Simplifies the type signature of a type.
55
55
  *
56
56
  * @example
57
- * import * as Types from "effect/Types"
57
+ * import type { Types } from "effect"
58
58
  *
59
59
  * type Res = Types.Simplify<{ a: number } & { b: number }> // { a: number; b: number; }
60
60
  *
@@ -69,7 +69,7 @@ export type Simplify<A> = {
69
69
  * Determines if two types are equal.
70
70
  *
71
71
  * @example
72
- * import * as Types from "effect/Types"
72
+ * import type { Types } from "effect"
73
73
  *
74
74
  * type Res1 = Types.Equals<{ a: number }, { a: number }> // true
75
75
  * type Res2 = Types.Equals<{ a: number }, { b: number }> // false
@@ -86,7 +86,7 @@ export type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends <
86
86
  * Determines if a record contains any of the given keys.
87
87
  *
88
88
  * @example
89
- * import * as Types from "effect/Types"
89
+ * import type { Types } from "effect"
90
90
  *
91
91
  * type Res1 = Types.Has<{ a: number }, "a" | "b"> // true
92
92
  * type Res2 = Types.Has<{ c: number }, "a" | "b"> // false
@@ -102,7 +102,7 @@ export type Has<A, Key extends string> = (Key extends infer K ? K extends keyof
102
102
  * Merges two object where the keys of the left object take precedence in the case of a conflict.
103
103
  *
104
104
  * @example
105
- * import * as Types from "effect/Types"
105
+ * import type { Types } from "effect"
106
106
  * type MergeLeft = Types.MergeLeft<{ a: number, b: number; }, { a: string }> // { a: number; b: number; }
107
107
  *
108
108
  * @since 2.0.0
@@ -118,7 +118,7 @@ export type MergeLeft<K, H> = Simplify<
118
118
  * Merges two object where the keys of the right object take precedence in the case of a conflict.
119
119
  *
120
120
  * @example
121
- * import * as Types from "effect/Types"
121
+ * import type { Types } from "effect"
122
122
  * type MergeRight = Types.MergeRight<{ a: number, b: number; }, { a: string }> // { a: string; b: number; }
123
123
  *
124
124
  * @since 2.0.0
@@ -153,7 +153,7 @@ export type Concurrency = number | "unbounded" | "inherit"
153
153
  * Make all properties in `T` mutable. Supports arrays, tuples, and records as well.
154
154
  *
155
155
  * @example
156
- * import type * as Types from "effect/Types"
156
+ * import type { Types } from "effect"
157
157
  *
158
158
  * type MutableStruct = Types.Mutable<{ readonly a: string; readonly b: number }> // { a: string; b: number; }
159
159
  *
@@ -174,7 +174,7 @@ export type Mutable<T> = {
174
174
  * Like `Types.Mutable`, but works recursively.
175
175
  *
176
176
  * @example
177
- * import type * as Types from "effect/Types"
177
+ * import type { Types } from "effect"
178
178
  *
179
179
  * type DeepMutableStruct = Types.DeepMutable<{
180
180
  * readonly a: string;
package/src/Utils.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  * @since 2.0.0
3
3
  */
4
4
  import { identity } from "./Function.js"
5
+ import { globalValue } from "./GlobalValue.js"
5
6
  import type { Kind, TypeLambda } from "./HKT.js"
6
7
  import { getBugErrorMessage } from "./internal/errors.js"
7
8
  import { isNullable, isObject } from "./Predicate.js"
@@ -24,7 +25,7 @@ import type * as Types from "./Types.js"
24
25
  * @category symbols
25
26
  * @since 2.0.0
26
27
  */
27
- export const GenKindTypeId = Symbol.for("effect/Gen/GenKind")
28
+ export const GenKindTypeId: unique symbol = Symbol.for("effect/Gen/GenKind")
28
29
 
29
30
  /**
30
31
  * @category symbols
@@ -716,7 +717,7 @@ function add64(
716
717
  /**
717
718
  * @since 3.0.6
718
719
  */
719
- export const YieldWrapTypeId = Symbol.for("effect/Utils/YieldWrap")
720
+ export const YieldWrapTypeId: unique symbol = Symbol.for("effect/Utils/YieldWrap")
720
721
 
721
722
  /**
722
723
  * @since 3.0.6
@@ -746,3 +747,40 @@ export function yieldWrapGet<T>(self: YieldWrap<T>): T {
746
747
  }
747
748
  throw new Error(getBugErrorMessage("yieldWrapGet"))
748
749
  }
750
+
751
+ /**
752
+ * Note: this is an experimental feature made available to allow custom matchers in tests, not to be directly used yet in user code
753
+ *
754
+ * @since 3.1.1
755
+ * @status experimental
756
+ * @category modifiers
757
+ */
758
+ export const structuralRegionState = globalValue(
759
+ "effect/Utils/isStructuralRegion",
760
+ (): { enabled: boolean; tester: ((a: unknown, b: unknown) => boolean) | undefined } => ({
761
+ enabled: false,
762
+ tester: undefined
763
+ })
764
+ )
765
+
766
+ /**
767
+ * Note: this is an experimental feature made available to allow custom matchers in tests, not to be directly used yet in user code
768
+ *
769
+ * @since 3.1.1
770
+ * @status experimental
771
+ * @category modifiers
772
+ */
773
+ export const structuralRegion = <A>(body: () => A, tester?: (a: unknown, b: unknown) => boolean): A => {
774
+ const current = structuralRegionState.enabled
775
+ const currentTester = structuralRegionState.tester
776
+ structuralRegionState.enabled = true
777
+ if (tester) {
778
+ structuralRegionState.tester = tester
779
+ }
780
+ try {
781
+ return body()
782
+ } finally {
783
+ structuralRegionState.enabled = current
784
+ structuralRegionState.tester = currentTester
785
+ }
786
+ }
@@ -25,12 +25,13 @@ import type * as Random from "../Random.js"
25
25
  import * as Ref from "../Ref.js"
26
26
  import type * as runtimeFlagsPatch from "../RuntimeFlagsPatch.js"
27
27
  import * as Tracer from "../Tracer.js"
28
- import type { MergeRecord, NoInfer } from "../Types.js"
28
+ import type { NoInfer } from "../Types.js"
29
29
  import { yieldWrapGet } from "../Utils.js"
30
30
  import * as internalCause from "./cause.js"
31
31
  import { clockTag } from "./clock.js"
32
32
  import * as core from "./core.js"
33
33
  import * as defaultServices from "./defaultServices.js"
34
+ import * as doNotation from "./doNotation.js"
34
35
  import * as fiberRefsPatch from "./fiberRefs/patch.js"
35
36
  import type { FiberRuntime } from "./fiberRuntime.js"
36
37
  import * as metricLabel from "./metric/label.js"
@@ -369,56 +370,39 @@ export const Do: Effect.Effect<{}> = core.succeed({})
369
370
 
370
371
  /* @internal */
371
372
  export const bind: {
372
- <N extends string, K, A, E2, R2>(
373
- tag: Exclude<N, keyof K>,
374
- f: (_: K) => Effect.Effect<A, E2, R2>
375
- ): <E, R>(self: Effect.Effect<K, E, R>) => Effect.Effect<MergeRecord<K, { [k in N]: A }>, E2 | E, R2 | R>
376
- <K, E, R, N extends string, A, E2, R2>(
377
- self: Effect.Effect<K, E, R>,
378
- tag: Exclude<N, keyof K>,
379
- f: (_: K) => Effect.Effect<A, E2, R2>
380
- ): Effect.Effect<MergeRecord<K, { [k in N]: A }>, E2 | E, R2 | R>
381
- } = dual(3, <K, E, R, N extends string, A, E2, R2>(
382
- self: Effect.Effect<K, E, R>,
383
- tag: Exclude<N, keyof K>,
384
- f: (_: K) => Effect.Effect<A, E2, R2>
385
- ): Effect.Effect<MergeRecord<K, { [k in N]: A }>, E2 | E, R2 | R> =>
386
- core.flatMap(self, (k) =>
387
- core.map(
388
- f(k),
389
- (a): MergeRecord<K, { [k in N]: A }> => ({ ...k, [tag]: a } as any)
390
- )))
373
+ <N extends string, A extends object, B, E2, R2>(
374
+ name: Exclude<N, keyof A>,
375
+ f: (a: A) => Effect.Effect<B, E2, R2>
376
+ ): <E1, R1>(
377
+ self: Effect.Effect<A, E1, R1>
378
+ ) => Effect.Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E2 | E1, R2 | R1>
379
+ <A extends object, N extends string, E1, R1, B, E2, R2>(
380
+ self: Effect.Effect<A, E1, R1>,
381
+ name: Exclude<N, keyof A>,
382
+ f: (a: A) => Effect.Effect<B, E2, R2>
383
+ ): Effect.Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E1 | E2, R1 | R2>
384
+ } = doNotation.bind<Effect.EffectTypeLambda>(core.map, core.flatMap)
391
385
 
392
386
  /* @internal */
393
387
  export const bindTo: {
394
- <N extends string>(tag: N): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<Record<N, A>, E, R>
395
- <A, E, R, N extends string>(self: Effect.Effect<A, E, R>, tag: N): Effect.Effect<Record<N, A>, E, R>
396
- } = dual(
397
- 2,
398
- <A, E, R, N extends string>(self: Effect.Effect<A, E, R>, tag: N): Effect.Effect<Record<N, A>, E, R> =>
399
- core.map(self, (a) => ({ [tag]: a } as Record<N, A>))
400
- )
388
+ <N extends string>(name: N): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<{ [K in N]: A }, E, R>
389
+ <A, E, R, N extends string>(self: Effect.Effect<A, E, R>, name: N): Effect.Effect<{ [K in N]: A }, E, R>
390
+ } = doNotation.bindTo<Effect.EffectTypeLambda>(core.map)
401
391
 
402
392
  /* @internal */
403
393
  export const let_: {
404
- <N extends string, K, A>(
405
- tag: Exclude<N, keyof K>,
406
- f: (_: K) => A
407
- ): <E, R>(self: Effect.Effect<K, E, R>) => Effect.Effect<MergeRecord<K, { [k in N]: A }>, E, R>
408
- <K, E, R, N extends string, A>(
409
- self: Effect.Effect<K, E, R>,
410
- tag: Exclude<N, keyof K>,
411
- f: (_: K) => A
412
- ): Effect.Effect<MergeRecord<K, { [k in N]: A }>, E, R>
413
- } = dual(3, <K, E, R, N extends string, A>(
414
- self: Effect.Effect<K, E, R>,
415
- tag: Exclude<N, keyof K>,
416
- f: (_: K) => A
417
- ): Effect.Effect<MergeRecord<K, { [k in N]: A }>, E, R> =>
418
- core.map(
419
- self,
420
- (k): MergeRecord<K, { [k in N]: A }> => ({ ...k, [tag]: f(k) } as any)
421
- ))
394
+ <N extends string, A extends object, B>(
395
+ name: Exclude<N, keyof A>,
396
+ f: (a: A) => B
397
+ ): <E, R>(
398
+ self: Effect.Effect<A, E, R>
399
+ ) => Effect.Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E, R>
400
+ <A extends object, N extends string, E, R, B>(
401
+ self: Effect.Effect<A, E, R>,
402
+ name: Exclude<N, keyof A>,
403
+ f: (a: A) => B
404
+ ): Effect.Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E, R>
405
+ } = doNotation.let_<Effect.EffectTypeLambda>(core.map)
422
406
 
423
407
  /* @internal */
424
408
  export const dropUntil: {
@@ -197,10 +197,18 @@ class EffectPrimitiveFailure {
197
197
  this._tag = _op
198
198
  }
199
199
  [Equal.symbol](this: {}, that: unknown) {
200
- return this === that
200
+ return exitIsExit(that) && that._op === "Failure" &&
201
+ // @ts-expect-error
202
+ Equal.equals(this.effect_instruction_i0, that.effect_instruction_i0)
201
203
  }
202
204
  [Hash.symbol](this: {}) {
203
- return Hash.cached(this, Hash.random(this))
205
+ return pipe(
206
+ // @ts-expect-error
207
+ Hash.string(this._tag),
208
+ // @ts-expect-error
209
+ Hash.combine(Hash.hash(this.effect_instruction_i0)),
210
+ Hash.cached(this)
211
+ )
204
212
  }
205
213
  get cause() {
206
214
  return this.effect_instruction_i0
@@ -238,10 +246,18 @@ class EffectPrimitiveSuccess {
238
246
  this._tag = _op
239
247
  }
240
248
  [Equal.symbol](this: {}, that: unknown) {
241
- return this === that
249
+ return exitIsExit(that) && that._op === "Success" &&
250
+ // @ts-expect-error
251
+ Equal.equals(this.effect_instruction_i0, that.effect_instruction_i0)
242
252
  }
243
253
  [Hash.symbol](this: {}) {
244
- return Hash.cached(this, Hash.random(this))
254
+ return pipe(
255
+ // @ts-expect-error
256
+ Hash.string(this._tag),
257
+ // @ts-expect-error
258
+ Hash.combine(Hash.hash(this.effect_instruction_i0)),
259
+ Hash.cached(this)
260
+ )
245
261
  }
246
262
  get value() {
247
263
  return this.effect_instruction_i0
@@ -0,0 +1,77 @@
1
+ import { dual } from "../Function.js"
2
+ import type { Kind, TypeLambda } from "../HKT.js"
3
+
4
+ type Map<F extends TypeLambda> = {
5
+ <A, B>(f: (a: A) => B): <R, O, E>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, B>
6
+ <R, O, E, A, B>(self: Kind<F, R, O, E, A>, f: (a: A) => B): Kind<F, R, O, E, B>
7
+ }
8
+
9
+ type FlatMap<F extends TypeLambda> = {
10
+ <A, R2, O2, E2, B>(
11
+ f: (a: A) => Kind<F, R2, O2, E2, B>
12
+ ): <R1, O1, E1>(self: Kind<F, R1, O1, E1, A>) => Kind<F, R1 & R2, O1 | O2, E1 | E2, B>
13
+ <R1, O1, E1, A, R2, O2, E2, B>(
14
+ self: Kind<F, R1, O1, E1, A>,
15
+ f: (a: A) => Kind<F, R2, O2, E2, B>
16
+ ): Kind<F, R1 & R2, O1 | O2, E1 | E2, B>
17
+ }
18
+
19
+ /** @internal */
20
+ export const let_ = <F extends TypeLambda>(
21
+ map: Map<F>
22
+ ): {
23
+ <N extends string, A extends object, B>(
24
+ name: Exclude<N, keyof A>,
25
+ f: (a: A) => B
26
+ ): <R, O, E>(
27
+ self: Kind<F, R, O, E, A>
28
+ ) => Kind<F, R, O, E, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>
29
+ <R, O, E, A extends object, N extends string, B>(
30
+ self: Kind<F, R, O, E, A>,
31
+ name: Exclude<N, keyof A>,
32
+ f: (a: A) => B
33
+ ): Kind<F, R, O, E, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>
34
+ } =>
35
+ dual(3, <R, O, E, A extends object, N extends string, B>(
36
+ self: Kind<F, R, O, E, A>,
37
+ name: Exclude<N, keyof A>,
38
+ f: (a: A) => B
39
+ ): Kind<F, R, O, E, { [K in keyof A | N]: K extends keyof A ? A[K] : B }> =>
40
+ map(self, (a) => Object.assign({}, a, { [name]: f(a) }) as any))
41
+
42
+ /** @internal */
43
+ export const bindTo = <F extends TypeLambda>(map: Map<F>): {
44
+ <N extends string>(
45
+ name: N
46
+ ): <R, O, E, A>(self: Kind<F, R, O, E, A>) => Kind<F, R, O, E, { [K in N]: A }>
47
+ <R, O, E, A, N extends string>(
48
+ self: Kind<F, R, O, E, A>,
49
+ name: N
50
+ ): Kind<F, R, O, E, { [K in N]: A }>
51
+ } =>
52
+ dual(2, <R, O, E, A, N extends string>(
53
+ self: Kind<F, R, O, E, A>,
54
+ name: N
55
+ ): Kind<F, R, O, E, { [K in N]: A }> => map(self, (a) => ({ [name]: a } as { [K in N]: A })))
56
+
57
+ /** @internal */
58
+ export const bind = <F extends TypeLambda>(map: Map<F>, flatMap: FlatMap<F>): {
59
+ <N extends string, A extends object, R2, O2, E2, B>(
60
+ name: Exclude<N, keyof A>,
61
+ f: (a: A) => Kind<F, R2, O2, E2, B>
62
+ ): <R1, O1, E1>(
63
+ self: Kind<F, R1, O1, E1, A>
64
+ ) => Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>
65
+ <R1, O1, E1, A extends object, N extends string, R2, O2, E2, B>(
66
+ self: Kind<F, R1, O1, E1, A>,
67
+ name: Exclude<N, keyof A>,
68
+ f: (a: A) => Kind<F, R2, O2, E2, B>
69
+ ): Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }>
70
+ } =>
71
+ dual(3, <R1, O1, E1, A, N extends string, R2, O2, E2, B>(
72
+ self: Kind<F, R1, O1, E1, A>,
73
+ name: Exclude<N, keyof A>,
74
+ f: (a: A) => Kind<F, R2, O2, E2, B>
75
+ ): Kind<F, R1 & R2, O1 | O2, E1 | E2, { [K in keyof A | N]: K extends keyof A ? A[K] : B }> =>
76
+ flatMap(self, (a) =>
77
+ map(f(a), (b) => Object.assign({}, a, { [name]: b }) as { [K in keyof A | N]: K extends keyof A ? A[K] : B })))