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/Context.ts CHANGED
@@ -99,7 +99,7 @@ export declare namespace Tag {
99
99
  * @param key - A key that will be used to compare tags.
100
100
  *
101
101
  * @example
102
- * import * as Context from "effect/Context"
102
+ * import { Context } from "effect"
103
103
  *
104
104
  * assert.strictEqual(Context.GenericTag("PORT").key === Context.GenericTag("PORT").key, true)
105
105
  *
@@ -146,7 +146,7 @@ export const unsafeMake: <Services>(unsafeMap: Map<string, any>) => Context<Serv
146
146
  * @param input - The value to be checked if it is a `Context`.
147
147
  *
148
148
  * @example
149
- * import * as Context from "effect/Context"
149
+ * import { Context } from "effect"
150
150
  *
151
151
  * assert.strictEqual(Context.isContext(Context.empty()), true)
152
152
  *
@@ -161,7 +161,7 @@ export const isContext: (input: unknown) => input is Context<never> = internal.i
161
161
  * @param input - The value to be checked if it is a `Tag`.
162
162
  *
163
163
  * @example
164
- * import * as Context from "effect/Context"
164
+ * import { Context } from "effect"
165
165
  *
166
166
  * assert.strictEqual(Context.isTag(Context.GenericTag("Tag")), true)
167
167
  *
@@ -174,7 +174,7 @@ export const isTag: (input: unknown) => input is Tag<any, any> = internal.isTag
174
174
  * Returns an empty `Context`.
175
175
  *
176
176
  * @example
177
- * import * as Context from "effect/Context"
177
+ * import { Context } from "effect"
178
178
  *
179
179
  * assert.strictEqual(Context.isContext(Context.empty()), true)
180
180
  *
@@ -187,7 +187,7 @@ export const empty: () => Context<never> = internal.empty
187
187
  * Creates a new `Context` with a single service associated to the tag.
188
188
  *
189
189
  * @example
190
- * import * as Context from "effect/Context"
190
+ * import { Context } from "effect"
191
191
  *
192
192
  * const Port = Context.GenericTag<{ PORT: number }>("Port")
193
193
  *
@@ -205,8 +205,7 @@ export const make: <T extends Tag<any, any>>(tag: T, service: Tag.Service<T>) =>
205
205
  * Adds a service to a given `Context`.
206
206
  *
207
207
  * @example
208
- * import * as Context from "effect/Context"
209
- * import { pipe } from "effect/Function"
208
+ * import { Context, pipe } from "effect"
210
209
  *
211
210
  * const Port = Context.GenericTag<{ PORT: number }>("Port")
212
211
  * const Timeout = Context.GenericTag<{ TIMEOUT: number }>("Timeout")
@@ -242,8 +241,7 @@ export const add: {
242
241
  * @param tag - The `Tag` of the service to retrieve.
243
242
  *
244
243
  * @example
245
- * import * as Context from "effect/Context"
246
- * import { pipe } from "effect/Function"
244
+ * import { pipe, Context } from "effect"
247
245
  *
248
246
  * const Port = Context.GenericTag<{ PORT: number }>("Port")
249
247
  * const Timeout = Context.GenericTag<{ TIMEOUT: number }>("Timeout")
@@ -273,7 +271,7 @@ export const get: {
273
271
  * @param tag - The `Tag` of the service to retrieve.
274
272
  *
275
273
  * @example
276
- * import * as Context from "effect/Context"
274
+ * import { Context } from "effect"
277
275
  *
278
276
  * const Port = Context.GenericTag<{ PORT: number }>("Port")
279
277
  * const Timeout = Context.GenericTag<{ TIMEOUT: number }>("Timeout")
@@ -299,16 +297,15 @@ export const unsafeGet: {
299
297
  * @param tag - The `Tag` of the service to retrieve.
300
298
  *
301
299
  * @example
302
- * import * as Context from "effect/Context"
303
- * import * as O from "effect/Option"
300
+ * import { Context, Option } from "effect"
304
301
  *
305
302
  * const Port = Context.GenericTag<{ PORT: number }>("Port")
306
303
  * const Timeout = Context.GenericTag<{ TIMEOUT: number }>("Timeout")
307
304
  *
308
305
  * const Services = Context.make(Port, { PORT: 8080 })
309
306
  *
310
- * assert.deepStrictEqual(Context.getOption(Services, Port), O.some({ PORT: 8080 }))
311
- * assert.deepStrictEqual(Context.getOption(Services, Timeout), O.none())
307
+ * assert.deepStrictEqual(Context.getOption(Services, Port), Option.some({ PORT: 8080 }))
308
+ * assert.deepStrictEqual(Context.getOption(Services, Timeout), Option.none())
312
309
  *
313
310
  * @since 2.0.0
314
311
  * @category getters
@@ -325,7 +322,7 @@ export const getOption: {
325
322
  * @param that - The second `Context` to merge.
326
323
  *
327
324
  * @example
328
- * import * as Context from "effect/Context"
325
+ * import { Context } from "effect"
329
326
  *
330
327
  * const Port = Context.GenericTag<{ PORT: number }>("Port")
331
328
  * const Timeout = Context.GenericTag<{ TIMEOUT: number }>("Timeout")
@@ -352,9 +349,7 @@ export const merge: {
352
349
  * @param tags - The list of `Tag`s to be included in the new `Context`.
353
350
  *
354
351
  * @example
355
- * import * as Context from "effect/Context"
356
- * import { pipe } from "effect/Function"
357
- * import * as O from "effect/Option"
352
+ * import { pipe, Context, Option } from "effect"
358
353
  *
359
354
  * const Port = Context.GenericTag<{ PORT: number }>("Port")
360
355
  * const Timeout = Context.GenericTag<{ TIMEOUT: number }>("Timeout")
@@ -366,8 +361,8 @@ export const merge: {
366
361
  *
367
362
  * const Services = pipe(someContext, Context.pick(Port))
368
363
  *
369
- * assert.deepStrictEqual(Context.getOption(Services, Port), O.some({ PORT: 8080 }))
370
- * assert.deepStrictEqual(Context.getOption(Services, Timeout), O.none())
364
+ * assert.deepStrictEqual(Context.getOption(Services, Port), Option.some({ PORT: 8080 }))
365
+ * assert.deepStrictEqual(Context.getOption(Services, Timeout), Option.none())
371
366
  *
372
367
  * @since 2.0.0
373
368
  */
package/src/Cron.ts CHANGED
@@ -170,8 +170,7 @@ export const isParseError = (u: unknown): u is ParseError => hasProperty(u, Pars
170
170
  * @param cron - The cron expression to parse.
171
171
  *
172
172
  * @example
173
- * import * as Cron from "effect/Cron"
174
- * import * as Either from "effect/Either"
173
+ * import { Cron, Either } from "effect"
175
174
  *
176
175
  * // At 04:00 on every day-of-month from 8 through 14.
177
176
  * assert.deepStrictEqual(Cron.parse("0 4 8-14 * *"), Either.right(Cron.make({
@@ -208,8 +207,7 @@ export const parse = (cron: string): Either.Either<Cron, ParseError> => {
208
207
  * @param date - The `Date` to check against.
209
208
  *
210
209
  * @example
211
- * import * as Cron from "effect/Cron"
212
- * import * as Either from "effect/Either"
210
+ * import { Cron, Either } from "effect"
213
211
  *
214
212
  * const cron = Either.getOrThrow(Cron.parse("0 4 8-14 * *"))
215
213
  * assert.deepStrictEqual(Cron.match(cron, new Date("2021-01-08 04:00:00")), true)
@@ -258,8 +256,7 @@ export const match = (cron: Cron, date: Date): boolean => {
258
256
  * Uses the current time as a starting point if no value is provided for `now`.
259
257
  *
260
258
  * @example
261
- * import * as Cron from "effect/Cron"
262
- * import * as Either from "effect/Either"
259
+ * import { Cron, Either } from "effect"
263
260
  *
264
261
  * const after = new Date("2021-01-01 00:00:00")
265
262
  * const cron = Either.getOrThrow(Cron.parse("0 4 8-14 * *"))
package/src/Data.ts CHANGED
@@ -26,8 +26,7 @@ export declare namespace Case {
26
26
 
27
27
  /**
28
28
  * @example
29
- * import * as Data from "effect/Data"
30
- * import * as Equal from "effect/Equal"
29
+ * import { Data, Equal } from "effect"
31
30
  *
32
31
  * const alice = Data.struct({ name: "Alice", age: 30 })
33
32
  *
@@ -53,8 +52,7 @@ export const unsafeStruct = <A extends Record<string, any>>(as: A): { readonly [
53
52
 
54
53
  /**
55
54
  * @example
56
- * import * as Data from "effect/Data"
57
- * import * as Equal from "effect/Equal"
55
+ * import { Data, Equal } from "effect"
58
56
  *
59
57
  * const alice = Data.tuple("Alice", 30)
60
58
  *
@@ -73,8 +71,7 @@ export const tuple = <As extends ReadonlyArray<any>>(...as: As): Readonly<As> =>
73
71
 
74
72
  /**
75
73
  * @example
76
- * import * as Data from "effect/Data"
77
- * import * as Equal from "effect/Equal"
74
+ * import { Data, Equal } from "effect"
78
75
  *
79
76
  * const alice = Data.struct({ name: "Alice", age: 30 })
80
77
  * const bob = Data.struct({ name: "Bob", age: 40 })
@@ -112,8 +109,7 @@ export {
112
109
  * Provides a constructor for the specified `Case`.
113
110
  *
114
111
  * @example
115
- * import * as Data from "effect/Data"
116
- * import * as Equal from "effect/Equal"
112
+ * import { Data, Equal } from "effect"
117
113
  *
118
114
  * interface Person {
119
115
  * readonly name: string
@@ -141,7 +137,7 @@ export {
141
137
  * Provides a tagged constructor for the specified `Case`.
142
138
  *
143
139
  * @example
144
- * import * as Data from "effect/Data"
140
+ * import { Data } from "effect"
145
141
  *
146
142
  * interface Person {
147
143
  * readonly _tag: "Person" // the tag
@@ -170,8 +166,7 @@ export const tagged = <A extends { readonly _tag: string }>(
170
166
  * Provides a constructor for a Case Class.
171
167
  *
172
168
  * @example
173
- * import * as Data from "effect/Data"
174
- * import * as Equal from "effect/Equal"
169
+ * import { Data, Equal } from "effect"
175
170
  *
176
171
  * class Person extends Data.Class<{ readonly name: string }> {}
177
172
  *
@@ -196,8 +191,7 @@ export const Class: new<A extends Record<string, any> = {}>(
196
191
  * Provides a Tagged constructor for a Case Class.
197
192
  *
198
193
  * @example
199
- * import * as Data from "effect/Data"
200
- * import * as Equal from "effect/Equal"
194
+ * import { Data, Equal } from "effect"
201
195
  *
202
196
  * class Person extends Data.TaggedClass("Person")<{ readonly name: string }> {}
203
197
  *
@@ -240,7 +234,7 @@ export const Structural: new<A>(
240
234
  * Create a tagged enum data type, which is a union of `Data` structs.
241
235
  *
242
236
  * ```ts
243
- * import * as Data from "effect/Data"
237
+ * import { Data } from "effect"
244
238
  *
245
239
  * type HttpError = Data.TaggedEnum<{
246
240
  * BadRequest: { readonly status: 400, readonly message: string }
@@ -358,7 +352,7 @@ export declare namespace TaggedEnum {
358
352
  * the constructor.
359
353
  *
360
354
  * @example
361
- * import * as Data from "effect/Data"
355
+ * import { Data } from "effect"
362
356
  *
363
357
  * const { BadRequest, NotFound } = Data.taggedEnum<
364
358
  * | { readonly _tag: "BadRequest"; readonly status: 400; readonly message: string }
@@ -368,7 +362,7 @@ export declare namespace TaggedEnum {
368
362
  * const notFound = NotFound({ status: 404, message: "Not Found" })
369
363
  *
370
364
  * @example
371
- * import * as Data from "effect/Data"
365
+ * import { Data } from "effect"
372
366
  *
373
367
  * type MyResult<E, A> = Data.TaggedEnum<{
374
368
  * Failure: { readonly error: E }
package/src/Duration.ts CHANGED
@@ -694,7 +694,7 @@ export const equals: {
694
694
  * @since 2.0.0
695
695
  *
696
696
  * @example
697
- * import * as Duration from "effect/Duration"
697
+ * import { Duration } from "effect"
698
698
  *
699
699
  * Duration.format(Duration.millis(1000)) // "1s"
700
700
  * Duration.format(Duration.millis(1001)) // "1s 1ms"
package/src/Effect.ts CHANGED
@@ -56,7 +56,7 @@ import * as Scheduler from "./Scheduler.js"
56
56
  import type * as Scope from "./Scope.js"
57
57
  import type * as Supervisor from "./Supervisor.js"
58
58
  import type * as Tracer from "./Tracer.js"
59
- import type { Concurrency, Covariant, MergeRecord, NoInfer, NotFunction } from "./Types.js"
59
+ import type { Concurrency, Covariant, NoInfer, NotFunction } from "./Types.js"
60
60
  import type * as Unify from "./Unify.js"
61
61
  import type { YieldWrap } from "./Utils.js"
62
62
 
@@ -321,8 +321,7 @@ export const cachedFunction: <A, B, E, R>(
321
321
  * evaluated multiple times.
322
322
  *
323
323
  * @example
324
- * import * as Effect from "effect/Effect"
325
- * import * as Console from "effect/Console"
324
+ * import { Effect, Console } from "effect"
326
325
  *
327
326
  * const program = Effect.gen(function* (_) {
328
327
  * const twice = Console.log("twice")
@@ -958,8 +957,7 @@ export const validateAll: {
958
957
  * If `elements` is empty then `Effect.fail([])` is returned.
959
958
  *
960
959
  * @example
961
- * import * as Effect from "effect/Effect"
962
- * import * as Exit from "effect/Exit"
960
+ * import { Effect, Exit } from "effect"
963
961
  *
964
962
  * const f = (n: number) => (n > 0 ? Effect.succeed(n) : Effect.fail(`${n} is negative`))
965
963
  *
@@ -1035,7 +1033,7 @@ export const asyncEffect: <A, E, R, R3, E2, R2>(
1035
1033
  * It is meant to be called with a bag of instructions that become available in the "this" of the effect.
1036
1034
  *
1037
1035
  * @example
1038
- * import * as Effect from "effect/Effect"
1036
+ * import { Effect } from "effect"
1039
1037
  *
1040
1038
  * const throwingFunction = () => { throw new Error() }
1041
1039
  * const blowUp = Effect.custom(throwingFunction, function() {
@@ -3263,56 +3261,148 @@ export const updateService: {
3263
3261
  // -------------------------------------------------------------------------------------
3264
3262
 
3265
3263
  /**
3266
- * @since 2.0.0
3264
+ * 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`.
3265
+ *
3266
+ * Here's how the do simulation works:
3267
+ *
3268
+ * 1. Start the do simulation using the `Do` value
3269
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Effect` values
3270
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
3271
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
3272
+ *
3273
+ * @see {@link bind}
3274
+ * @see {@link bindTo}
3275
+ * @see {@link let_ let}
3276
+ *
3277
+ * @example
3278
+ * import { Effect, pipe } from "effect"
3279
+ *
3280
+ * const result = pipe(
3281
+ * Effect.Do,
3282
+ * Effect.bind("x", () => Effect.succeed(2)),
3283
+ * Effect.bind("y", () => Effect.succeed(3)),
3284
+ * Effect.let("sum", ({ x, y }) => x + y)
3285
+ * )
3286
+ * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
3287
+ *
3267
3288
  * @category do notation
3289
+ * @since 2.0.0
3268
3290
  */
3269
3291
  export const Do: Effect<{}> = effect.Do
3270
3292
 
3271
3293
  /**
3272
- * Binds an effectful value in a `do` scope
3294
+ * 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`.
3295
+ *
3296
+ * Here's how the do simulation works:
3297
+ *
3298
+ * 1. Start the do simulation using the `Do` value
3299
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Effect` values
3300
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
3301
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
3302
+ *
3303
+ * @see {@link Do}
3304
+ * @see {@link bindTo}
3305
+ * @see {@link let_ let}
3306
+ *
3307
+ * @example
3308
+ * import { Effect, pipe } from "effect"
3309
+ *
3310
+ * const result = pipe(
3311
+ * Effect.Do,
3312
+ * Effect.bind("x", () => Effect.succeed(2)),
3313
+ * Effect.bind("y", () => Effect.succeed(3)),
3314
+ * Effect.let("sum", ({ x, y }) => x + y)
3315
+ * )
3316
+ * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
3273
3317
  *
3274
- * @since 2.0.0
3275
3318
  * @category do notation
3319
+ * @since 2.0.0
3276
3320
  */
3277
3321
  export const bind: {
3278
- <N extends string, K, A, E2, R2>(
3279
- tag: Exclude<N, keyof K>,
3280
- f: (_: K) => Effect<A, E2, R2>
3281
- ): <E, R>(self: Effect<K, E, R>) => Effect<MergeRecord<K, { [k in N]: A }>, E2 | E, R2 | R>
3282
- <K, E, R, N extends string, A, E2, R2>(
3283
- self: Effect<K, E, R>,
3284
- tag: Exclude<N, keyof K>,
3285
- f: (_: K) => Effect<A, E2, R2>
3286
- ): Effect<MergeRecord<K, { [k in N]: A }>, E2 | E, R2 | R>
3322
+ <N extends string, A extends object, B, E2, R2>(
3323
+ name: Exclude<N, keyof A>,
3324
+ f: (a: A) => Effect<B, E2, R2>
3325
+ ): <E1, R1>(self: Effect<A, E1, R1>) => Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E2 | E1, R2 | R1>
3326
+ <A extends object, N extends string, E1, R1, B, E2, R2>(
3327
+ self: Effect<A, E1, R1>,
3328
+ name: Exclude<N, keyof A>,
3329
+ f: (a: A) => Effect<B, E2, R2>
3330
+ ): Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E1 | E2, R1 | R2>
3287
3331
  } = effect.bind
3288
3332
 
3289
3333
  /**
3334
+ * 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`.
3335
+ *
3336
+ * Here's how the do simulation works:
3337
+ *
3338
+ * 1. Start the do simulation using the `Do` value
3339
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Effect` values
3340
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
3341
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
3342
+ *
3343
+ * @see {@link Do}
3344
+ * @see {@link bind}
3345
+ * @see {@link let_ let}
3346
+ *
3347
+ * @example
3348
+ * import { Effect, pipe } from "effect"
3349
+ *
3350
+ * const result = pipe(
3351
+ * Effect.Do,
3352
+ * Effect.bind("x", () => Effect.succeed(2)),
3353
+ * Effect.bind("y", () => Effect.succeed(3)),
3354
+ * Effect.let("sum", ({ x, y }) => x + y)
3355
+ * )
3356
+ * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
3357
+ *
3290
3358
  * @category do notation
3291
3359
  * @since 2.0.0
3292
3360
  */
3293
3361
  export const bindTo: {
3294
- <N extends string>(tag: N): <A, E, R>(self: Effect<A, E, R>) => Effect<Record<N, A>, E, R>
3295
- <A, E, R, N extends string>(self: Effect<A, E, R>, tag: N): Effect<Record<N, A>, E, R>
3362
+ <N extends string>(name: N): <A, E, R>(self: Effect<A, E, R>) => Effect<{ [K in N]: A }, E, R>
3363
+ <A, E, R, N extends string>(self: Effect<A, E, R>, name: N): Effect<{ [K in N]: A }, E, R>
3296
3364
  } = effect.bindTo
3297
3365
 
3298
3366
  const let_: {
3299
- <N extends string, K, A>(
3300
- tag: Exclude<N, keyof K>,
3301
- f: (_: K) => A
3302
- ): <E, R>(self: Effect<K, E, R>) => Effect<MergeRecord<K, { [k in N]: A }>, E, R>
3303
- <K, E, R, N extends string, A>(
3304
- self: Effect<K, E, R>,
3305
- tag: Exclude<N, keyof K>,
3306
- f: (_: K) => A
3307
- ): Effect<MergeRecord<K, { [k in N]: A }>, E, R>
3367
+ <N extends string, A extends object, B>(
3368
+ name: Exclude<N, keyof A>,
3369
+ f: (a: A) => B
3370
+ ): <E, R>(self: Effect<A, E, R>) => Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E, R>
3371
+ <A extends object, N extends string, E, R, B>(
3372
+ self: Effect<A, E, R>,
3373
+ name: Exclude<N, keyof A>,
3374
+ f: (a: A) => B
3375
+ ): Effect<{ [K in N | keyof A]: K extends keyof A ? A[K] : B }, E, R>
3308
3376
  } = effect.let_
3309
3377
 
3310
3378
  export {
3311
3379
  /**
3312
- * Like bind for values
3380
+ * 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`.
3381
+ *
3382
+ * Here's how the do simulation works:
3383
+ *
3384
+ * 1. Start the do simulation using the `Do` value
3385
+ * 2. Within the do simulation scope, you can use the `bind` function to define variables and bind them to `Effect` values
3386
+ * 3. You can accumulate multiple `bind` statements to define multiple variables within the scope
3387
+ * 4. Inside the do simulation scope, you can also use the `let` function to define variables and bind them to simple values
3388
+ *
3389
+ * @see {@link Do}
3390
+ * @see {@link bind}
3391
+ * @see {@link bindTo}
3392
+ *
3393
+ * @example
3394
+ * import { Effect, pipe } from "effect"
3395
+ *
3396
+ * const result = pipe(
3397
+ * Effect.Do,
3398
+ * Effect.bind("x", () => Effect.succeed(2)),
3399
+ * Effect.bind("y", () => Effect.succeed(3)),
3400
+ * Effect.let("sum", ({ x, y }) => x + y)
3401
+ * )
3402
+ * assert.deepStrictEqual(Effect.runSync(result), { x: 2, y: 3, sum: 5 })
3313
3403
  *
3314
- * @since 2.0.0
3315
3404
  * @category do notation
3405
+ * @since 2.0.0
3316
3406
  */
3317
3407
  let_ as let
3318
3408
  }
@@ -3628,7 +3718,7 @@ export const flatMap: {
3628
3718
  * - a function returning an effect
3629
3719
  *
3630
3720
  * @example
3631
- * import * as Effect from "effect/Effect"
3721
+ * import { Effect } from "effect"
3632
3722
  *
3633
3723
  * assert.deepStrictEqual(Effect.runSync(Effect.succeed("aa").pipe(Effect.andThen(1))), 1)
3634
3724
  * assert.deepStrictEqual(Effect.runSync(Effect.succeed("aa").pipe(Effect.andThen((s) => s.length))), 2)