effect 3.1.1 → 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 (257) 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/FiberHandle.js.map +1 -1
  22. package/dist/cjs/FiberMap.js.map +1 -1
  23. package/dist/cjs/FiberSet.js.map +1 -1
  24. package/dist/cjs/Function.js +2 -2
  25. package/dist/cjs/Function.js.map +1 -1
  26. package/dist/cjs/Iterable.js +10 -13
  27. package/dist/cjs/Iterable.js.map +1 -1
  28. package/dist/cjs/List.js +2 -2
  29. package/dist/cjs/Metric.js +5 -7
  30. package/dist/cjs/Metric.js.map +1 -1
  31. package/dist/cjs/Number.js +20 -21
  32. package/dist/cjs/Number.js.map +1 -1
  33. package/dist/cjs/Option.js +223 -164
  34. package/dist/cjs/Option.js.map +1 -1
  35. package/dist/cjs/Order.js +1 -2
  36. package/dist/cjs/Order.js.map +1 -1
  37. package/dist/cjs/Ordering.js +2 -2
  38. package/dist/cjs/Predicate.js +9 -12
  39. package/dist/cjs/Predicate.js.map +1 -1
  40. package/dist/cjs/Readable.js.map +1 -1
  41. package/dist/cjs/Record.js +35 -47
  42. package/dist/cjs/Record.js.map +1 -1
  43. package/dist/cjs/RegExp.js +1 -1
  44. package/dist/cjs/Request.js +2 -2
  45. package/dist/cjs/Request.js.map +1 -1
  46. package/dist/cjs/Stream.js +82 -4
  47. package/dist/cjs/Stream.js.map +1 -1
  48. package/dist/cjs/String.js +81 -111
  49. package/dist/cjs/String.js.map +1 -1
  50. package/dist/cjs/Struct.js +13 -19
  51. package/dist/cjs/Struct.js.map +1 -1
  52. package/dist/cjs/Subscribable.js.map +1 -1
  53. package/dist/cjs/Symbol.js +3 -3
  54. package/dist/cjs/TestAnnotation.js.map +1 -1
  55. package/dist/cjs/TestAnnotationMap.js.map +1 -1
  56. package/dist/cjs/TestAnnotations.js.map +1 -1
  57. package/dist/cjs/TestClock.js.map +1 -1
  58. package/dist/cjs/TestLive.js.map +1 -1
  59. package/dist/cjs/TestSized.js.map +1 -1
  60. package/dist/cjs/Trie.js +28 -44
  61. package/dist/cjs/Trie.js.map +1 -1
  62. package/dist/cjs/Utils.js.map +1 -1
  63. package/dist/cjs/internal/core-effect.js +4 -11
  64. package/dist/cjs/internal/core-effect.js.map +1 -1
  65. package/dist/cjs/internal/doNotation.js +23 -0
  66. package/dist/cjs/internal/doNotation.js.map +1 -0
  67. package/dist/cjs/internal/groupBy.js.map +1 -1
  68. package/dist/cjs/internal/stream.js +3 -7
  69. package/dist/cjs/internal/stream.js.map +1 -1
  70. package/dist/cjs/internal/version.js +1 -1
  71. package/dist/dts/Array.d.ts +10 -13
  72. package/dist/dts/Array.d.ts.map +1 -1
  73. package/dist/dts/BigDecimal.d.ts +14 -17
  74. package/dist/dts/BigDecimal.d.ts.map +1 -1
  75. package/dist/dts/BigInt.d.ts +41 -46
  76. package/dist/dts/BigInt.d.ts.map +1 -1
  77. package/dist/dts/Boolean.d.ts +13 -13
  78. package/dist/dts/Brand.d.ts +3 -3
  79. package/dist/dts/Chunk.d.ts +3 -3
  80. package/dist/dts/Context.d.ts +15 -20
  81. package/dist/dts/Context.d.ts.map +1 -1
  82. package/dist/dts/Cron.d.ts +3 -6
  83. package/dist/dts/Cron.d.ts.map +1 -1
  84. package/dist/dts/Data.d.ts +10 -16
  85. package/dist/dts/Data.d.ts.map +1 -1
  86. package/dist/dts/Duration.d.ts +1 -1
  87. package/dist/dts/Effect.d.ts +120 -26
  88. package/dist/dts/Effect.d.ts.map +1 -1
  89. package/dist/dts/Either.d.ts +155 -64
  90. package/dist/dts/Either.d.ts.map +1 -1
  91. package/dist/dts/FiberHandle.d.ts.map +1 -1
  92. package/dist/dts/FiberMap.d.ts.map +1 -1
  93. package/dist/dts/FiberSet.d.ts.map +1 -1
  94. package/dist/dts/Function.d.ts +4 -2
  95. package/dist/dts/Function.d.ts.map +1 -1
  96. package/dist/dts/HashMap.d.ts +2 -2
  97. package/dist/dts/Iterable.d.ts +10 -13
  98. package/dist/dts/Iterable.d.ts.map +1 -1
  99. package/dist/dts/List.d.ts +2 -2
  100. package/dist/dts/Metric.d.ts +5 -7
  101. package/dist/dts/Metric.d.ts.map +1 -1
  102. package/dist/dts/Number.d.ts +20 -21
  103. package/dist/dts/Number.d.ts.map +1 -1
  104. package/dist/dts/Option.d.ts +245 -155
  105. package/dist/dts/Option.d.ts.map +1 -1
  106. package/dist/dts/Order.d.ts +1 -2
  107. package/dist/dts/Order.d.ts.map +1 -1
  108. package/dist/dts/Ordering.d.ts +2 -2
  109. package/dist/dts/Predicate.d.ts +9 -12
  110. package/dist/dts/Predicate.d.ts.map +1 -1
  111. package/dist/dts/Readable.d.ts.map +1 -1
  112. package/dist/dts/Record.d.ts +35 -47
  113. package/dist/dts/Record.d.ts.map +1 -1
  114. package/dist/dts/RegExp.d.ts +1 -1
  115. package/dist/dts/Request.d.ts +2 -2
  116. package/dist/dts/Request.d.ts.map +1 -1
  117. package/dist/dts/Stream.d.ts +136 -31
  118. package/dist/dts/Stream.d.ts.map +1 -1
  119. package/dist/dts/String.d.ts +81 -111
  120. package/dist/dts/String.d.ts.map +1 -1
  121. package/dist/dts/Struct.d.ts +13 -19
  122. package/dist/dts/Struct.d.ts.map +1 -1
  123. package/dist/dts/Subscribable.d.ts.map +1 -1
  124. package/dist/dts/Symbol.d.ts +3 -3
  125. package/dist/dts/TestAnnotation.d.ts.map +1 -1
  126. package/dist/dts/TestAnnotationMap.d.ts.map +1 -1
  127. package/dist/dts/TestAnnotations.d.ts.map +1 -1
  128. package/dist/dts/TestClock.d.ts +1 -5
  129. package/dist/dts/TestClock.d.ts.map +1 -1
  130. package/dist/dts/TestLive.d.ts.map +1 -1
  131. package/dist/dts/TestSized.d.ts.map +1 -1
  132. package/dist/dts/Trie.d.ts +28 -44
  133. package/dist/dts/Trie.d.ts.map +1 -1
  134. package/dist/dts/Types.d.ts +10 -10
  135. package/dist/dts/Utils.d.ts.map +1 -1
  136. package/dist/dts/internal/doNotation.d.ts +2 -0
  137. package/dist/dts/internal/doNotation.d.ts.map +1 -0
  138. package/dist/dts/internal/stream.d.ts.map +1 -1
  139. package/dist/esm/Array.js +10 -13
  140. package/dist/esm/Array.js.map +1 -1
  141. package/dist/esm/BigDecimal.js +14 -17
  142. package/dist/esm/BigDecimal.js.map +1 -1
  143. package/dist/esm/BigInt.js +41 -46
  144. package/dist/esm/BigInt.js.map +1 -1
  145. package/dist/esm/Boolean.js +13 -13
  146. package/dist/esm/Brand.js +2 -2
  147. package/dist/esm/Chunk.js +3 -3
  148. package/dist/esm/Context.js +15 -20
  149. package/dist/esm/Context.js.map +1 -1
  150. package/dist/esm/Cron.js +3 -6
  151. package/dist/esm/Cron.js.map +1 -1
  152. package/dist/esm/Data.js +9 -15
  153. package/dist/esm/Data.js.map +1 -1
  154. package/dist/esm/Duration.js +1 -1
  155. package/dist/esm/Effect.js +101 -11
  156. package/dist/esm/Effect.js.map +1 -1
  157. package/dist/esm/Either.js +141 -61
  158. package/dist/esm/Either.js.map +1 -1
  159. package/dist/esm/FiberHandle.js.map +1 -1
  160. package/dist/esm/FiberMap.js.map +1 -1
  161. package/dist/esm/FiberSet.js.map +1 -1
  162. package/dist/esm/Function.js +2 -2
  163. package/dist/esm/Function.js.map +1 -1
  164. package/dist/esm/Iterable.js +10 -13
  165. package/dist/esm/Iterable.js.map +1 -1
  166. package/dist/esm/List.js +2 -2
  167. package/dist/esm/Metric.js +5 -7
  168. package/dist/esm/Metric.js.map +1 -1
  169. package/dist/esm/Number.js +20 -21
  170. package/dist/esm/Number.js.map +1 -1
  171. package/dist/esm/Option.js +249 -164
  172. package/dist/esm/Option.js.map +1 -1
  173. package/dist/esm/Order.js +1 -2
  174. package/dist/esm/Order.js.map +1 -1
  175. package/dist/esm/Ordering.js +2 -2
  176. package/dist/esm/Predicate.js +9 -12
  177. package/dist/esm/Predicate.js.map +1 -1
  178. package/dist/esm/Readable.js.map +1 -1
  179. package/dist/esm/Record.js +35 -47
  180. package/dist/esm/Record.js.map +1 -1
  181. package/dist/esm/RegExp.js +1 -1
  182. package/dist/esm/Request.js +2 -2
  183. package/dist/esm/Request.js.map +1 -1
  184. package/dist/esm/Stream.js +107 -6
  185. package/dist/esm/Stream.js.map +1 -1
  186. package/dist/esm/String.js +81 -111
  187. package/dist/esm/String.js.map +1 -1
  188. package/dist/esm/Struct.js +13 -19
  189. package/dist/esm/Struct.js.map +1 -1
  190. package/dist/esm/Subscribable.js.map +1 -1
  191. package/dist/esm/Symbol.js +3 -3
  192. package/dist/esm/TestAnnotation.js.map +1 -1
  193. package/dist/esm/TestAnnotationMap.js.map +1 -1
  194. package/dist/esm/TestAnnotations.js.map +1 -1
  195. package/dist/esm/TestClock.js.map +1 -1
  196. package/dist/esm/TestLive.js.map +1 -1
  197. package/dist/esm/TestSized.js.map +1 -1
  198. package/dist/esm/Trie.js +28 -44
  199. package/dist/esm/Trie.js.map +1 -1
  200. package/dist/esm/Utils.js.map +1 -1
  201. package/dist/esm/internal/core-effect.js +4 -11
  202. package/dist/esm/internal/core-effect.js.map +1 -1
  203. package/dist/esm/internal/doNotation.js +14 -0
  204. package/dist/esm/internal/doNotation.js.map +1 -0
  205. package/dist/esm/internal/groupBy.js.map +1 -1
  206. package/dist/esm/internal/stream.js +3 -7
  207. package/dist/esm/internal/stream.js.map +1 -1
  208. package/dist/esm/internal/version.js +1 -1
  209. package/package.json +1 -1
  210. package/src/Array.ts +10 -13
  211. package/src/BigDecimal.ts +14 -17
  212. package/src/BigInt.ts +41 -46
  213. package/src/Boolean.ts +13 -13
  214. package/src/Brand.ts +3 -3
  215. package/src/Chunk.ts +3 -3
  216. package/src/Context.ts +15 -20
  217. package/src/Cron.ts +3 -6
  218. package/src/Data.ts +10 -16
  219. package/src/Duration.ts +1 -1
  220. package/src/Effect.ts +122 -32
  221. package/src/Either.ts +161 -94
  222. package/src/FiberHandle.ts +1 -1
  223. package/src/FiberMap.ts +1 -1
  224. package/src/FiberSet.ts +1 -1
  225. package/src/Function.ts +4 -2
  226. package/src/HashMap.ts +2 -2
  227. package/src/Iterable.ts +10 -13
  228. package/src/List.ts +2 -2
  229. package/src/Metric.ts +5 -7
  230. package/src/Number.ts +20 -21
  231. package/src/Option.ts +250 -172
  232. package/src/Order.ts +1 -2
  233. package/src/Ordering.ts +2 -2
  234. package/src/Predicate.ts +9 -12
  235. package/src/Readable.ts +1 -1
  236. package/src/Record.ts +35 -47
  237. package/src/RegExp.ts +1 -1
  238. package/src/Request.ts +3 -3
  239. package/src/Stream.ts +137 -36
  240. package/src/String.ts +81 -111
  241. package/src/Struct.ts +13 -19
  242. package/src/Subscribable.ts +1 -1
  243. package/src/Symbol.ts +3 -3
  244. package/src/TestAnnotation.ts +1 -1
  245. package/src/TestAnnotationMap.ts +1 -1
  246. package/src/TestAnnotations.ts +1 -1
  247. package/src/TestClock.ts +1 -5
  248. package/src/TestLive.ts +1 -1
  249. package/src/TestSized.ts +1 -1
  250. package/src/Trie.ts +28 -44
  251. package/src/Types.ts +10 -10
  252. package/src/Utils.ts +2 -2
  253. package/src/internal/core-effect.ts +29 -45
  254. package/src/internal/doNotation.ts +77 -0
  255. package/src/internal/groupBy.ts +16 -16
  256. package/src/internal/stream.ts +34 -58
  257. package/src/internal/version.ts +1 -1
package/src/Either.ts CHANGED
@@ -7,12 +7,13 @@ import type { LazyArg } from "./Function.js"
7
7
  import { constNull, constUndefined, dual, identity } from "./Function.js"
8
8
  import type { TypeLambda } from "./HKT.js"
9
9
  import type { Inspectable } from "./Inspectable.js"
10
+ import * as doNotation from "./internal/doNotation.js"
10
11
  import * as either from "./internal/either.js"
11
12
  import type { Option } from "./Option.js"
12
13
  import type { Pipeable } from "./Pipeable.js"
13
14
  import type { Predicate, Refinement } from "./Predicate.js"
14
15
  import { isFunction } from "./Predicate.js"
15
- import type { Covariant, MergeRecord, NoInfer, NotFunction } from "./Types.js"
16
+ import type { Covariant, NoInfer, NotFunction } from "./Types.js"
16
17
  import type * as Unify from "./Unify.js"
17
18
  import * as Gen from "./Utils.js"
18
19
 
@@ -129,7 +130,7 @@ export const left: <L>(left: L) => Either<never, L> = either.left
129
130
  * the provided default as a `Left`.
130
131
  *
131
132
  * @example
132
- * import * as Either from 'effect/Either'
133
+ * import { Either } from "effect"
133
134
  *
134
135
  * assert.deepStrictEqual(Either.fromNullable(1, () => 'fallback'), Either.right(1))
135
136
  * assert.deepStrictEqual(Either.fromNullable(null, () => 'fallback'), Either.left('fallback'))
@@ -148,8 +149,7 @@ export const fromNullable: {
148
149
 
149
150
  /**
150
151
  * @example
151
- * import * as Either from 'effect/Either'
152
- * import * as Option from 'effect/Option'
152
+ * import { Either, Option } from "effect"
153
153
  *
154
154
  * assert.deepStrictEqual(Either.fromOption(Option.some(1), () => 'error'), Either.right(1))
155
155
  * assert.deepStrictEqual(Either.fromOption(Option.none(), () => 'error'), Either.left('error'))
@@ -208,11 +208,11 @@ export {
208
208
  * @param input - The value to test.
209
209
  *
210
210
  * @example
211
- * import { isEither, left, right } from 'effect/Either'
211
+ * import { Either } from "effect"
212
212
  *
213
- * assert.deepStrictEqual(isEither(right(1)), true)
214
- * assert.deepStrictEqual(isEither(left("a")), true)
215
- * assert.deepStrictEqual(isEither({ right: 1 }), false)
213
+ * assert.deepStrictEqual(Either.isEither(Either.right(1)), true)
214
+ * assert.deepStrictEqual(Either.isEither(Either.left("a")), true)
215
+ * assert.deepStrictEqual(Either.isEither({ right: 1 }), false)
216
216
  *
217
217
  * @category guards
218
218
  * @since 2.0.0
@@ -225,10 +225,10 @@ export const isEither: (input: unknown) => input is Either<unknown, unknown> = e
225
225
  * @param self - The `Either` to check.
226
226
  *
227
227
  * @example
228
- * import { isLeft, left, right } from 'effect/Either'
228
+ * import { Either } from "effect"
229
229
  *
230
- * assert.deepStrictEqual(isLeft(right(1)), false)
231
- * assert.deepStrictEqual(isLeft(left("a")), true)
230
+ * assert.deepStrictEqual(Either.isLeft(Either.right(1)), false)
231
+ * assert.deepStrictEqual(Either.isLeft(Either.left("a")), true)
232
232
  *
233
233
  * @category guards
234
234
  * @since 2.0.0
@@ -241,10 +241,10 @@ export const isLeft: <R, L>(self: Either<R, L>) => self is Left<L, R> = either.i
241
241
  * @param self - The `Either` to check.
242
242
  *
243
243
  * @example
244
- * import { isRight, left, right } from 'effect/Either'
244
+ * import { Either } from "effect"
245
245
  *
246
- * assert.deepStrictEqual(isRight(right(1)), true)
247
- * assert.deepStrictEqual(isRight(left("a")), false)
246
+ * assert.deepStrictEqual(Either.isRight(Either.right(1)), true)
247
+ * assert.deepStrictEqual(Either.isRight(Either.left("a")), false)
248
248
  *
249
249
  * @category guards
250
250
  * @since 2.0.0
@@ -257,11 +257,10 @@ export const isRight: <R, L>(self: Either<R, L>) => self is Right<L, R> = either
257
257
  * Alias of {@link toOption}.
258
258
  *
259
259
  * @example
260
- * import * as O from 'effect/Option'
261
- * import * as E from 'effect/Either'
260
+ * import { Either, Option } from "effect"
262
261
  *
263
- * assert.deepStrictEqual(E.getRight(E.right('ok')), O.some('ok'))
264
- * assert.deepStrictEqual(E.getRight(E.left('err')), O.none())
262
+ * assert.deepStrictEqual(Either.getRight(Either.right('ok')), Option.some('ok'))
263
+ * assert.deepStrictEqual(Either.getRight(Either.left('err')), Option.none())
265
264
  *
266
265
  * @category getters
267
266
  * @since 2.0.0
@@ -272,11 +271,10 @@ export const getRight: <R, L>(self: Either<R, L>) => Option<R> = either.getRight
272
271
  * Converts a `Either` to an `Option` discarding the value.
273
272
  *
274
273
  * @example
275
- * import * as O from 'effect/Option'
276
- * import * as E from 'effect/Either'
274
+ * import { Either, Option } from "effect"
277
275
  *
278
- * assert.deepStrictEqual(E.getLeft(E.right('ok')), O.none())
279
- * assert.deepStrictEqual(E.getLeft(E.left('err')), O.some('err'))
276
+ * assert.deepStrictEqual(Either.getLeft(Either.right('ok')), Option.none())
277
+ * assert.deepStrictEqual(Either.getLeft(Either.left('err')), Option.some('err'))
280
278
  *
281
279
  * @category getters
282
280
  * @since 2.0.0
@@ -360,16 +358,15 @@ export const map: {
360
358
  * if the value is a `Right` the inner value is applied to the `onRight` function.
361
359
  *
362
360
  * @example
363
- * import * as E from 'effect/Either'
364
- * import { pipe } from 'effect/Function'
361
+ * import { pipe, Either } from "effect"
365
362
  *
366
363
  * const onLeft = (strings: ReadonlyArray<string>): string => `strings: ${strings.join(', ')}`
367
364
  *
368
365
  * const onRight = (value: number): string => `Ok: ${value}`
369
366
  *
370
- * assert.deepStrictEqual(pipe(E.right(1), E.match({ onLeft, onRight })), 'Ok: 1')
367
+ * assert.deepStrictEqual(pipe(Either.right(1), Either.match({ onLeft, onRight })), 'Ok: 1')
371
368
  * assert.deepStrictEqual(
372
- * pipe(E.left(['string 1', 'string 2']), E.match({ onLeft, onRight })),
369
+ * pipe(Either.left(['string 1', 'string 2']), Either.match({ onLeft, onRight })),
373
370
  * 'strings: string 1, string 2'
374
371
  * )
375
372
  *
@@ -398,24 +395,23 @@ export const match: {
398
395
  * If the predicate fails, set the left value with the result of the provided function.
399
396
  *
400
397
  * @example
401
- * import * as E from 'effect/Either'
402
- * import { pipe } from 'effect/Function'
398
+ * import { pipe, Either } from "effect"
403
399
  *
404
400
  * const isPositive = (n: number): boolean => n > 0
405
401
  *
406
402
  * assert.deepStrictEqual(
407
403
  * pipe(
408
- * E.right(1),
409
- * E.filterOrLeft(isPositive, n => `${n} is not positive`)
404
+ * Either.right(1),
405
+ * Either.filterOrLeft(isPositive, n => `${n} is not positive`)
410
406
  * ),
411
- * E.right(1)
407
+ * Either.right(1)
412
408
  * )
413
409
  * assert.deepStrictEqual(
414
410
  * pipe(
415
- * E.right(0),
416
- * E.filterOrLeft(isPositive, n => `${n} is not positive`)
411
+ * Either.right(0),
412
+ * Either.filterOrLeft(isPositive, n => `${n} is not positive`)
417
413
  * ),
418
- * E.left("0 is not positive")
414
+ * Either.left("0 is not positive")
419
415
  * )
420
416
  *
421
417
  * @since 2.0.0
@@ -455,7 +451,7 @@ export const merge: <R, L>(self: Either<R, L>) => L | R = match({
455
451
  * Returns the wrapped value if it's a `Right` or a default value if is a `Left`.
456
452
  *
457
453
  * @example
458
- * import * as Either from 'effect/Either'
454
+ * import { Either } from "effect"
459
455
  *
460
456
  * assert.deepStrictEqual(Either.getOrElse(Either.right(1), (error) => error + "!"), 1)
461
457
  * assert.deepStrictEqual(Either.getOrElse(Either.left("not a number"), (error) => error + "!"), "not a number!")
@@ -473,7 +469,7 @@ export const getOrElse: {
473
469
 
474
470
  /**
475
471
  * @example
476
- * import * as Either from 'effect/Either'
472
+ * import { Either } from "effect"
477
473
  *
478
474
  * assert.deepStrictEqual(Either.getOrNull(Either.right(1)), 1)
479
475
  * assert.deepStrictEqual(Either.getOrNull(Either.left("a")), null)
@@ -485,7 +481,7 @@ export const getOrNull: <R, L>(self: Either<R, L>) => R | null = getOrElse(const
485
481
 
486
482
  /**
487
483
  * @example
488
- * import * as Either from 'effect/Either'
484
+ * import { Either } from "effect"
489
485
  *
490
486
  * assert.deepStrictEqual(Either.getOrUndefined(Either.right(1)), 1)
491
487
  * assert.deepStrictEqual(Either.getOrUndefined(Either.left("a")), undefined)
@@ -504,13 +500,13 @@ export const getOrUndefined: <R, L>(self: Either<R, L>) => R | undefined = getOr
504
500
  * @param onLeft - A function that will be called if the `Either` is `Left`. It returns the error to be thrown.
505
501
  *
506
502
  * @example
507
- * import * as E from "effect/Either"
503
+ * import { Either } from "effect"
508
504
  *
509
505
  * assert.deepStrictEqual(
510
- * E.getOrThrowWith(E.right(1), () => new Error('Unexpected Left')),
506
+ * Either.getOrThrowWith(Either.right(1), () => new Error('Unexpected Left')),
511
507
  * 1
512
508
  * )
513
- * assert.throws(() => E.getOrThrowWith(E.left("error"), () => new Error('Unexpected Left')))
509
+ * assert.throws(() => Either.getOrThrowWith(Either.left("error"), () => new Error('Unexpected Left')))
514
510
  *
515
511
  * @category getters
516
512
  * @since 2.0.0
@@ -534,10 +530,10 @@ export const getOrThrowWith: {
534
530
  * @throws `Error("getOrThrow called on a Left")`
535
531
  *
536
532
  * @example
537
- * import * as E from "effect/Either"
533
+ * import { Either } from "effect"
538
534
  *
539
- * assert.deepStrictEqual(E.getOrThrow(E.right(1)), 1)
540
- * assert.throws(() => E.getOrThrow(E.left("error")))
535
+ * assert.deepStrictEqual(Either.getOrThrow(Either.right(1)), 1)
536
+ * assert.throws(() => Either.getOrThrow(Either.left("error")))
541
537
  *
542
538
  * @category getters
543
539
  * @since 2.0.0
@@ -644,7 +640,7 @@ export const ap: {
644
640
  * @param fields - the struct of `Either`s to be sequenced.
645
641
  *
646
642
  * @example
647
- * import * as Either from "effect/Either"
643
+ * import { Either } from "effect"
648
644
  *
649
645
  * assert.deepStrictEqual(Either.all([Either.right(1), Either.right(2)]), Either.right([1, 2]))
650
646
  * assert.deepStrictEqual(Either.all({ right: Either.right(1), b: Either.right("hello") }), Either.right({ right: 1, b: "hello" }))
@@ -742,77 +738,148 @@ export const gen: Gen.Gen<EitherTypeLambda, Gen.Adapter<EitherTypeLambda>> = (f)
742
738
  // -------------------------------------------------------------------------------------
743
739
 
744
740
  /**
745
- * @since 2.4.0
741
+ * The "do simulation" in allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
742
+ *
743
+ * Here's how the do simulation works:
744
+ *
745
+ * 1. Start the do simulation using the `Do` value
746
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Either` values
747
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
748
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
749
+ *
750
+ * @see {@link bind}
751
+ * @see {@link bindTo}
752
+ * @see {@link let_ let}
753
+ *
754
+ * @example
755
+ * import { Either, pipe } from "effect"
756
+ *
757
+ * const result = pipe(
758
+ * Either.Do,
759
+ * Either.bind("x", () => Either.right(2)),
760
+ * Either.bind("y", () => Either.right(3)),
761
+ * Either.let("sum", ({ x, y }) => x + y)
762
+ * )
763
+ * assert.deepStrictEqual(result, Either.right({ x: 2, y: 3, sum: 5 }))
764
+ *
746
765
  * @category do notation
766
+ * @since 2.0.0
747
767
  */
748
768
  export const Do: Either<{}> = right({})
749
769
 
750
770
  /**
751
- * Binds an effectful value in a `do` scope
771
+ * The "do simulation" in allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
772
+ *
773
+ * Here's how the do simulation works:
774
+ *
775
+ * 1. Start the do simulation using the `Do` value
776
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Either` values
777
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
778
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
779
+ *
780
+ * @see {@link Do}
781
+ * @see {@link bindTo}
782
+ * @see {@link let_ let}
783
+ *
784
+ * @example
785
+ * import { Either, pipe } from "effect"
786
+ *
787
+ * const result = pipe(
788
+ * Either.Do,
789
+ * Either.bind("x", () => Either.right(2)),
790
+ * Either.bind("y", () => Either.right(3)),
791
+ * Either.let("sum", ({ x, y }) => x + y)
792
+ * )
793
+ * assert.deepStrictEqual(result, Either.right({ x: 2, y: 3, sum: 5 }))
752
794
  *
753
- * @since 2.4.0
754
795
  * @category do notation
796
+ * @since 2.0.0
755
797
  */
756
798
  export const bind: {
757
- <N extends string, K, A, E2>(
758
- tag: Exclude<N, keyof K>,
759
- f: (_: K) => Either<A, E2>
760
- ): <E>(self: Either<K, E>) => Either<MergeRecord<K, { [k in N]: A }>, E2 | E>
761
- <K, E, N extends string, A, E2>(
762
- self: Either<E, K>,
763
- tag: Exclude<N, keyof K>,
764
- f: (_: K) => Either<A, E2>
765
- ): Either<MergeRecord<K, { [k in N]: A }>, E2 | E>
766
- } = dual(3, <K, E, N extends string, A, E2>(
767
- self: Either<K, E>,
768
- tag: Exclude<N, keyof K>,
769
- f: (_: K) => Either<A, E2>
770
- ): Either<MergeRecord<K, { [k in N]: A }>, E2 | E> =>
771
- flatMap(self, (k) =>
772
- map(
773
- f(k),
774
- (a): MergeRecord<K, { [k in N]: A }> => ({ ...k, [tag]: a } as any)
775
- )))
799
+ <N extends string, A extends object, B, L2>(
800
+ name: Exclude<N, keyof A>,
801
+ f: (a: A) => Either<B, L2>
802
+ ): <L1>(self: Either<A, L1>) => Either<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, L1 | L2>
803
+ <A extends object, L1, N extends string, B, L2>(
804
+ self: Either<A, L1>,
805
+ name: Exclude<N, keyof A>,
806
+ f: (a: A) => Either<B, L2>
807
+ ): Either<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, L1 | L2>
808
+ } = doNotation.bind<EitherTypeLambda>(map, flatMap)
776
809
 
777
810
  /**
811
+ * The "do simulation" in allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
812
+ *
813
+ * Here's how the do simulation works:
814
+ *
815
+ * 1. Start the do simulation using the `Do` value
816
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Either` values
817
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
818
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
819
+ *
820
+ * @see {@link Do}
821
+ * @see {@link bind}
822
+ * @see {@link let_ let}
823
+ *
824
+ * @example
825
+ * import { Either, pipe } from "effect"
826
+ *
827
+ * const result = pipe(
828
+ * Either.Do,
829
+ * Either.bind("x", () => Either.right(2)),
830
+ * Either.bind("y", () => Either.right(3)),
831
+ * Either.let("sum", ({ x, y }) => x + y)
832
+ * )
833
+ * assert.deepStrictEqual(result, Either.right({ x: 2, y: 3, sum: 5 }))
834
+ *
778
835
  * @category do notation
779
- * @since 2.4.0
836
+ * @since 2.0.0
780
837
  */
781
838
  export const bindTo: {
782
- <N extends string>(tag: N): <A, E>(self: Either<A, E>) => Either<Record<N, A>, E>
783
- <A, E, N extends string>(self: Either<A, E>, tag: N): Either<Record<N, A>, E>
784
- } = dual(
785
- 2,
786
- <A, E, N extends string>(self: Either<A, E>, tag: N): Either<Record<N, A>, E> =>
787
- map(self, (a) => ({ [tag]: a } as Record<N, A>))
788
- )
839
+ <N extends string>(name: N): <R, L>(self: Either<R, L>) => Either<{ [K in N]: R }, L>
840
+ <R, L, N extends string>(self: Either<R, L>, name: N): Either<{ [K in N]: R }, L>
841
+ } = doNotation.bindTo<EitherTypeLambda>(map)
789
842
 
790
843
  const let_: {
791
- <N extends string, K, A>(
792
- tag: Exclude<N, keyof K>,
793
- f: (_: K) => A
794
- ): <E>(self: Either<K, E>) => Either<MergeRecord<K, { [k in N]: A }>, E>
795
- <K, E, N extends string, A>(
796
- self: Either<K, E>,
797
- tag: Exclude<N, keyof K>,
798
- f: (_: K) => A
799
- ): Either<MergeRecord<K, { [k in N]: A }>, E>
800
- } = dual(3, <K, E, N extends string, A>(
801
- self: Either<K, E>,
802
- tag: Exclude<N, keyof K>,
803
- f: (_: K) => A
804
- ): Either<MergeRecord<K, { [k in N]: A }>, E> =>
805
- map(
806
- self,
807
- (k): MergeRecord<K, { [k in N]: A }> => ({ ...k, [tag]: f(k) } as any)
808
- ))
844
+ <N extends string, R extends object, B>(
845
+ name: Exclude<N, keyof R>,
846
+ f: (r: R) => B
847
+ ): <L>(self: Either<R, L>) => Either<{ [K in N | keyof R]: K extends keyof R ? R[K] : B }, L>
848
+ <R extends object, L, N extends string, B>(
849
+ self: Either<R, L>,
850
+ name: Exclude<N, keyof R>,
851
+ f: (r: R) => B
852
+ ): Either<{ [K in N | keyof R]: K extends keyof R ? R[K] : B }, L>
853
+ } = doNotation.let_<EitherTypeLambda>(map)
809
854
 
810
855
  export {
811
856
  /**
812
- * Like bind for values
857
+ * The "do simulation" in allows you to write code in a more declarative style, similar to the "do notation" in other programming languages. It provides a way to define variables and perform operations on them using functions like `bind` and `let`.
858
+ *
859
+ * Here's how the do simulation works:
860
+ *
861
+ * 1. Start the do simulation using the `Do` value
862
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Either` values
863
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
864
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
865
+ *
866
+ * @see {@link Do}
867
+ * @see {@link bindTo}
868
+ * @see {@link bind}
869
+ *
870
+ * @example
871
+ * import { Either, pipe } from "effect"
872
+ *
873
+ * const result = pipe(
874
+ * Either.Do,
875
+ * Either.bind("x", () => Either.right(2)),
876
+ * Either.bind("y", () => Either.right(3)),
877
+ * Either.let("sum", ({ x, y }) => x + y)
878
+ * )
879
+ * assert.deepStrictEqual(result, Either.right({ x: 2, y: 3, sum: 5 }))
813
880
  *
814
- * @since 2.4.0
815
881
  * @category do notation
882
+ * @since 2.0.0
816
883
  */
817
884
  let_ as let
818
885
  }
@@ -22,7 +22,7 @@ import * as Runtime from "./Runtime.js"
22
22
  * @since 2.0.0
23
23
  * @categories type ids
24
24
  */
25
- export const TypeId = Symbol.for("effect/FiberHandle")
25
+ export const TypeId: unique symbol = Symbol.for("effect/FiberHandle")
26
26
 
27
27
  /**
28
28
  * @since 2.0.0
package/src/FiberMap.ts CHANGED
@@ -24,7 +24,7 @@ import * as Runtime from "./Runtime.js"
24
24
  * @since 2.0.0
25
25
  * @categories type ids
26
26
  */
27
- export const TypeId = Symbol.for("effect/FiberMap")
27
+ export const TypeId: unique symbol = Symbol.for("effect/FiberMap")
28
28
 
29
29
  /**
30
30
  * @since 2.0.0
package/src/FiberSet.ts CHANGED
@@ -22,7 +22,7 @@ import * as Runtime from "./Runtime.js"
22
22
  * @since 2.0.0
23
23
  * @categories type ids
24
24
  */
25
- export const TypeId = Symbol.for("effect/FiberSet")
25
+ export const TypeId: unique symbol = Symbol.for("effect/FiberSet")
26
26
 
27
27
  /**
28
28
  * @since 2.0.0
package/src/Function.ts CHANGED
@@ -17,7 +17,7 @@ export interface FunctionTypeLambda extends TypeLambda {
17
17
  * @param input - The value to test.
18
18
  *
19
19
  * @example
20
- * import { isFunction } from 'effect/Predicate'
20
+ * import { isFunction } from "effect/Predicate"
21
21
  *
22
22
  * assert.deepStrictEqual(isFunction(isFunction), true)
23
23
  * assert.deepStrictEqual(isFunction("function"), false)
@@ -154,7 +154,7 @@ export const dual: {
154
154
  *
155
155
  * @example
156
156
  * import { pipe, apply } from "effect/Function"
157
- * import { length } from 'effect/String'
157
+ * import { length } from "effect/String"
158
158
  *
159
159
  * assert.deepStrictEqual(pipe(length, apply("hello")), 5)
160
160
  *
@@ -408,6 +408,8 @@ export const untupled = <A extends ReadonlyArray<unknown>, B>(f: (a: A) => B): (
408
408
  *
409
409
  * @example
410
410
  * import { pipe } from "effect/Function"
411
+ * // Alternatively, you can use the following import syntax, as `pipe` is also conveniently exported from the `effect` entry point:
412
+ * // import { pipe } from "effect"
411
413
  *
412
414
  * const length = (s: string): number => s.length
413
415
  * const double = (n: number): number => n * 2
package/src/HashMap.ts CHANGED
@@ -40,7 +40,7 @@ export declare namespace HashMap {
40
40
  * This type-level utility extracts the key type `K` from a `HashMap<K, V>` type.
41
41
  *
42
42
  * @example
43
- * import * as HashMap from "effect/HashMap"
43
+ * import { HashMap } from "effect"
44
44
  *
45
45
  * declare const hm: HashMap.HashMap<string, number>
46
46
  *
@@ -55,7 +55,7 @@ export declare namespace HashMap {
55
55
  * This type-level utility extracts the value type `V` from a `HashMap<K, V>` type.
56
56
  *
57
57
  * @example
58
- * import * as HashMap from "effect/HashMap"
58
+ * import { HashMap } from "effect"
59
59
  *
60
60
  * declare const hm: HashMap.HashMap<string, number>
61
61
  *
package/src/Iterable.ts CHANGED
@@ -24,7 +24,7 @@ import type { NoInfer } from "./Types.js"
24
24
  * **Note**. `length` is normalized to an integer >= 1.
25
25
  *
26
26
  * @example
27
- * import { makeBy } from 'effect/Iterable'
27
+ * import { makeBy } from "effect/Iterable"
28
28
  *
29
29
  * assert.deepStrictEqual(Array.from(makeBy(n => n * 2, { length: 5 })), [0, 2, 4, 6, 8])
30
30
  *
@@ -56,7 +56,7 @@ export const makeBy = <A>(f: (i: number) => A, options?: {
56
56
  * If `end` is omitted, the range will not have an upper bound.
57
57
  *
58
58
  * @example
59
- * import { range } from 'effect/Iterable'
59
+ * import { range } from "effect/Iterable"
60
60
  *
61
61
  * assert.deepStrictEqual(Array.from(range(1, 3)), [1, 2, 3])
62
62
  *
@@ -78,7 +78,7 @@ export const range = (start: number, end?: number): Iterable<number> => {
78
78
  * **Note**. `n` is normalized to an integer >= 1.
79
79
  *
80
80
  * @example
81
- * import { replicate } from 'effect/Iterable'
81
+ * import { replicate } from "effect/Iterable"
82
82
  *
83
83
  * assert.deepStrictEqual(Array.from(replicate("a", 3)), ["a", "a", "a"])
84
84
  *
@@ -129,7 +129,7 @@ export const prepend: {
129
129
  * Prepends the specified prefix iterable to the beginning of the specified iterable.
130
130
  *
131
131
  * @example
132
- * import * as Iterable from "effect/Iterable"
132
+ * import { Iterable } from "effect"
133
133
  *
134
134
  * assert.deepStrictEqual(
135
135
  * Array.from(Iterable.prependAll([1, 2], ["a", "b"])),
@@ -806,11 +806,10 @@ export const filterMapWhile: {
806
806
  * Retrieves the `Some` values from an `Iterable` of `Option`s.
807
807
  *
808
808
  * @example
809
- * import { getSomes } from "effect/Iterable"
810
- * import { some, none } from "effect/Option"
809
+ * import { Iterable, Option } from "effect"
811
810
  *
812
811
  * assert.deepStrictEqual(
813
- * Array.from(getSomes([some(1), none(), some(2)])),
812
+ * Array.from(Iterable.getSomes([Option.some(1), Option.none(), Option.some(2)])),
814
813
  * [1, 2]
815
814
  * )
816
815
  *
@@ -823,11 +822,10 @@ export const getSomes: <A>(self: Iterable<Option<A>>) => Iterable<A> = filterMap
823
822
  * Retrieves the `Left` values from an `Iterable` of `Either`s.
824
823
  *
825
824
  * @example
826
- * import { getLefts } from "effect/Iterable"
827
- * import { right, left } from "effect/Either"
825
+ * import { Iterable, Either } from "effect"
828
826
  *
829
827
  * assert.deepStrictEqual(
830
- * Array.from(getLefts([right(1), left("err"), right(2)])),
828
+ * Array.from(Iterable.getLefts([Either.right(1), Either.left("err"), Either.right(2)])),
831
829
  * ["err"]
832
830
  * )
833
831
  *
@@ -840,11 +838,10 @@ export const getLefts = <R, L>(self: Iterable<Either<R, L>>): Iterable<L> => fil
840
838
  * Retrieves the `Right` values from an `Iterable` of `Either`s.
841
839
  *
842
840
  * @example
843
- * import { getRights } from "effect/Iterable"
844
- * import { right, left } from "effect/Either"
841
+ * import { Iterable, Either } from "effect"
845
842
  *
846
843
  * assert.deepStrictEqual(
847
- * Array.from(getRights([right(1), left("err"), right(2)])),
844
+ * Array.from(Iterable.getRights([Either.right(1), Either.left("err"), Either.right(2)])),
848
845
  * [1, 2]
849
846
  * )
850
847
  *
package/src/List.ts CHANGED
@@ -324,7 +324,7 @@ export const append: {
324
324
  * If either list is non-empty, the result is also a non-empty list.
325
325
  *
326
326
  * @example
327
- * import * as List from "effect/List"
327
+ * import { List } from "effect"
328
328
  *
329
329
  * assert.deepStrictEqual(
330
330
  * List.make(1, 2).pipe(List.appendAll(List.make("a", "b")), List.toArray),
@@ -357,7 +357,7 @@ export const prepend: {
357
357
  * If either list is non-empty, the result is also a non-empty list.
358
358
  *
359
359
  * @example
360
- * import * as List from "effect/List"
360
+ * import { List } from "effect"
361
361
  *
362
362
  * assert.deepStrictEqual(
363
363
  * List.make(1, 2).pipe(List.prependAll(List.make("a", "b")), List.toArray),
package/src/Metric.ts CHANGED
@@ -165,7 +165,7 @@ export const mapInput: {
165
165
  * - incremental - Set to 'true' for a counter that only increases. With this configuration, Effect ensures that non-incremental updates have no impact on the counter, making it exclusively suitable for counting upwards.
166
166
  *
167
167
  * @example
168
- * import * as Metric from "effect/Metric"
168
+ * import { Metric } from "effect"
169
169
  *
170
170
  * const numberCounter = Metric.counter("count", {
171
171
  * description: "A number counter"
@@ -206,7 +206,7 @@ export const counter: {
206
206
  * @param description - An optional description of the Frequency metric.
207
207
  *
208
208
  * @example
209
- * import * as Metric from "effect/Metric"
209
+ * import { Metric } from "effect"
210
210
  *
211
211
  * const errorFrequency = Metric.frequency("error_frequency", {
212
212
  * description: "Counts the occurrences of errors."
@@ -254,7 +254,7 @@ export const fromMetricKey: <Type extends MetricKeyType.MetricKeyType<any, any>>
254
254
  * - bigint - Indicates if the counter uses 'bigint' data type.
255
255
  *
256
256
  * @example
257
- * import * as Metric from "effect/Metric"
257
+ * import { Metric } from "effect"
258
258
  *
259
259
  * const numberGauge = Metric.gauge("memory_usage", {
260
260
  * description: "A gauge for memory usage"
@@ -288,8 +288,7 @@ export const gauge: {
288
288
  * @param description - A description of the histogram metric.
289
289
  *
290
290
  * @example
291
- * import * as Metric from "effect/Metric"
292
- * import * as MetricBoundaries from "effect/MetricBoundaries"
291
+ * import { Metric, MetricBoundaries } from "effect"
293
292
  *
294
293
  * const latencyHistogram = Metric.histogram("latency_histogram",
295
294
  * MetricBoundaries.linear({ start: 0, width: 10, count: 11 }),
@@ -393,8 +392,7 @@ export const sync: <Out>(evaluate: LazyArg<Out>) => Metric<void, unknown, Out> =
393
392
  * - description - An optional description of the Summary metric.
394
393
  *
395
394
  * @example
396
- * import * as Metric from "effect/Metric"
397
- * import * as Chunk from "effect/Chunk"
395
+ * import { Metric, Chunk } from "effect"
398
396
  *
399
397
  * const responseTimesSummary = Metric.summary({
400
398
  * name: "response_times_summary",