effect 3.12.0 → 3.12.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 (169) hide show
  1. package/dist/cjs/BigDecimal.js +3 -3
  2. package/dist/cjs/Effect.js +2957 -928
  3. package/dist/cjs/Effect.js.map +1 -1
  4. package/dist/cjs/GlobalValue.js +8 -6
  5. package/dist/cjs/GlobalValue.js.map +1 -1
  6. package/dist/cjs/HashMap.js +2 -2
  7. package/dist/cjs/HashMap.js.map +1 -1
  8. package/dist/cjs/ManagedRuntime.js.map +1 -1
  9. package/dist/cjs/Predicate.js.map +1 -1
  10. package/dist/cjs/Request.js +3 -3
  11. package/dist/cjs/Request.js.map +1 -1
  12. package/dist/cjs/RequestBlock.js +7 -7
  13. package/dist/cjs/RequestBlock.js.map +1 -1
  14. package/dist/cjs/Runtime.js.map +1 -1
  15. package/dist/cjs/Schema.js +5 -8
  16. package/dist/cjs/Schema.js.map +1 -1
  17. package/dist/cjs/Stream.js +5 -5
  18. package/dist/cjs/Stream.js.map +1 -1
  19. package/dist/cjs/internal/channel.js +3 -3
  20. package/dist/cjs/internal/channel.js.map +1 -1
  21. package/dist/cjs/internal/core-effect.js +3 -3
  22. package/dist/cjs/internal/core-effect.js.map +1 -1
  23. package/dist/cjs/internal/core.js +19 -33
  24. package/dist/cjs/internal/core.js.map +1 -1
  25. package/dist/cjs/internal/defaultServices.js +2 -2
  26. package/dist/cjs/internal/defaultServices.js.map +1 -1
  27. package/dist/cjs/internal/effect/circular.js +4 -4
  28. package/dist/cjs/internal/effect/circular.js.map +1 -1
  29. package/dist/cjs/internal/fiberRefs/patch.js +5 -5
  30. package/dist/cjs/internal/fiberRefs/patch.js.map +1 -1
  31. package/dist/cjs/internal/fiberRuntime.js +40 -37
  32. package/dist/cjs/internal/fiberRuntime.js.map +1 -1
  33. package/dist/cjs/internal/fiberScope.js.map +1 -1
  34. package/dist/cjs/internal/layer/circular.js +2 -2
  35. package/dist/cjs/internal/layer/circular.js.map +1 -1
  36. package/dist/cjs/internal/logSpan.js +10 -3
  37. package/dist/cjs/internal/logSpan.js.map +1 -1
  38. package/dist/cjs/internal/logger-circular.js +2 -2
  39. package/dist/cjs/internal/logger-circular.js.map +1 -1
  40. package/dist/cjs/internal/logger.js +44 -118
  41. package/dist/cjs/internal/logger.js.map +1 -1
  42. package/dist/cjs/internal/metric.js +3 -3
  43. package/dist/cjs/internal/metric.js.map +1 -1
  44. package/dist/cjs/internal/reloadable.js +7 -7
  45. package/dist/cjs/internal/reloadable.js.map +1 -1
  46. package/dist/cjs/internal/resource.js +2 -2
  47. package/dist/cjs/internal/resource.js.map +1 -1
  48. package/dist/cjs/internal/runtime.js +7 -7
  49. package/dist/cjs/internal/runtime.js.map +1 -1
  50. package/dist/cjs/internal/scopedCache.js +9 -9
  51. package/dist/cjs/internal/scopedCache.js.map +1 -1
  52. package/dist/cjs/internal/stream.js +28 -28
  53. package/dist/cjs/internal/stream.js.map +1 -1
  54. package/dist/cjs/internal/subscriptionRef.js +4 -4
  55. package/dist/cjs/internal/subscriptionRef.js.map +1 -1
  56. package/dist/cjs/internal/synchronizedRef.js.map +1 -1
  57. package/dist/cjs/internal/version.js +1 -1
  58. package/dist/dts/BigDecimal.d.ts +3 -3
  59. package/dist/dts/Effect.d.ts +6541 -2072
  60. package/dist/dts/Effect.d.ts.map +1 -1
  61. package/dist/dts/GlobalValue.d.ts.map +1 -1
  62. package/dist/dts/Layer.d.ts +3 -3
  63. package/dist/dts/Layer.d.ts.map +1 -1
  64. package/dist/dts/ManagedRuntime.d.ts +2 -2
  65. package/dist/dts/ManagedRuntime.d.ts.map +1 -1
  66. package/dist/dts/Predicate.d.ts +1 -1
  67. package/dist/dts/Predicate.d.ts.map +1 -1
  68. package/dist/dts/Runtime.d.ts +2 -2
  69. package/dist/dts/Runtime.d.ts.map +1 -1
  70. package/dist/dts/Schema.d.ts.map +1 -1
  71. package/dist/dts/Utils.d.ts +4 -4
  72. package/dist/dts/Utils.d.ts.map +1 -1
  73. package/dist/dts/internal/core-effect.d.ts.map +1 -1
  74. package/dist/dts/internal/core.d.ts.map +1 -1
  75. package/dist/dts/internal/fiberScope.d.ts.map +1 -1
  76. package/dist/dts/internal/logger.d.ts +1 -1
  77. package/dist/dts/internal/logger.d.ts.map +1 -1
  78. package/dist/esm/BigDecimal.js +3 -3
  79. package/dist/esm/Effect.js +2958 -929
  80. package/dist/esm/Effect.js.map +1 -1
  81. package/dist/esm/GlobalValue.js +8 -6
  82. package/dist/esm/GlobalValue.js.map +1 -1
  83. package/dist/esm/HashMap.js +2 -2
  84. package/dist/esm/HashMap.js.map +1 -1
  85. package/dist/esm/ManagedRuntime.js.map +1 -1
  86. package/dist/esm/Predicate.js.map +1 -1
  87. package/dist/esm/Request.js +3 -3
  88. package/dist/esm/Request.js.map +1 -1
  89. package/dist/esm/RequestBlock.js +7 -7
  90. package/dist/esm/RequestBlock.js.map +1 -1
  91. package/dist/esm/Runtime.js.map +1 -1
  92. package/dist/esm/Schema.js +5 -8
  93. package/dist/esm/Schema.js.map +1 -1
  94. package/dist/esm/Stream.js +5 -5
  95. package/dist/esm/Stream.js.map +1 -1
  96. package/dist/esm/internal/channel.js +3 -3
  97. package/dist/esm/internal/channel.js.map +1 -1
  98. package/dist/esm/internal/core-effect.js +3 -3
  99. package/dist/esm/internal/core-effect.js.map +1 -1
  100. package/dist/esm/internal/core.js +16 -28
  101. package/dist/esm/internal/core.js.map +1 -1
  102. package/dist/esm/internal/defaultServices.js +2 -2
  103. package/dist/esm/internal/defaultServices.js.map +1 -1
  104. package/dist/esm/internal/effect/circular.js +4 -4
  105. package/dist/esm/internal/effect/circular.js.map +1 -1
  106. package/dist/esm/internal/fiberRefs/patch.js +5 -5
  107. package/dist/esm/internal/fiberRefs/patch.js.map +1 -1
  108. package/dist/esm/internal/fiberRuntime.js +40 -37
  109. package/dist/esm/internal/fiberRuntime.js.map +1 -1
  110. package/dist/esm/internal/fiberScope.js.map +1 -1
  111. package/dist/esm/internal/layer/circular.js +2 -2
  112. package/dist/esm/internal/layer/circular.js.map +1 -1
  113. package/dist/esm/internal/logSpan.js +7 -1
  114. package/dist/esm/internal/logSpan.js.map +1 -1
  115. package/dist/esm/internal/logger-circular.js +2 -2
  116. package/dist/esm/internal/logger-circular.js.map +1 -1
  117. package/dist/esm/internal/logger.js +45 -119
  118. package/dist/esm/internal/logger.js.map +1 -1
  119. package/dist/esm/internal/metric.js +3 -3
  120. package/dist/esm/internal/metric.js.map +1 -1
  121. package/dist/esm/internal/reloadable.js +7 -7
  122. package/dist/esm/internal/reloadable.js.map +1 -1
  123. package/dist/esm/internal/resource.js +2 -2
  124. package/dist/esm/internal/resource.js.map +1 -1
  125. package/dist/esm/internal/runtime.js +7 -7
  126. package/dist/esm/internal/runtime.js.map +1 -1
  127. package/dist/esm/internal/scopedCache.js +9 -9
  128. package/dist/esm/internal/scopedCache.js.map +1 -1
  129. package/dist/esm/internal/stream.js +28 -28
  130. package/dist/esm/internal/stream.js.map +1 -1
  131. package/dist/esm/internal/subscriptionRef.js +4 -4
  132. package/dist/esm/internal/subscriptionRef.js.map +1 -1
  133. package/dist/esm/internal/synchronizedRef.js.map +1 -1
  134. package/dist/esm/internal/version.js +1 -1
  135. package/package.json +1 -1
  136. package/src/BigDecimal.ts +3 -3
  137. package/src/Effect.ts +6587 -2108
  138. package/src/GlobalValue.ts +8 -6
  139. package/src/HashMap.ts +2 -2
  140. package/src/Layer.ts +3 -3
  141. package/src/ManagedRuntime.ts +3 -2
  142. package/src/Predicate.ts +2 -2
  143. package/src/Request.ts +3 -3
  144. package/src/RequestBlock.ts +7 -7
  145. package/src/Runtime.ts +2 -5
  146. package/src/Schema.ts +5 -8
  147. package/src/Stream.ts +5 -5
  148. package/src/Utils.ts +4 -4
  149. package/src/internal/channel.ts +3 -3
  150. package/src/internal/core-effect.ts +4 -6
  151. package/src/internal/core.ts +28 -54
  152. package/src/internal/defaultServices.ts +10 -10
  153. package/src/internal/effect/circular.ts +54 -49
  154. package/src/internal/fiberRefs/patch.ts +5 -5
  155. package/src/internal/fiberRuntime.ts +54 -48
  156. package/src/internal/fiberScope.ts +0 -1
  157. package/src/internal/layer/circular.ts +2 -2
  158. package/src/internal/logSpan.ts +8 -1
  159. package/src/internal/logger-circular.ts +2 -2
  160. package/src/internal/logger.ts +54 -145
  161. package/src/internal/metric.ts +3 -3
  162. package/src/internal/reloadable.ts +10 -10
  163. package/src/internal/resource.ts +2 -2
  164. package/src/internal/runtime.ts +8 -8
  165. package/src/internal/scopedCache.ts +23 -23
  166. package/src/internal/stream.ts +30 -30
  167. package/src/internal/subscriptionRef.ts +4 -4
  168. package/src/internal/synchronizedRef.ts +0 -1
  169. package/src/internal/version.ts +1 -1
@@ -14,13 +14,9 @@
14
14
  */
15
15
  import * as version from "./internal/version.js"
16
16
 
17
- const globalStoreId = Symbol.for(`effect/GlobalValue/globalStoreId/${version.getCurrentVersion()}`)
17
+ const globalStoreId = `effect/GlobalValue/globalStoreId/${version.getCurrentVersion()}`
18
18
 
19
- if (!(globalStoreId in globalThis)) {
20
- ;(globalThis as any)[globalStoreId] = new Map()
21
- }
22
-
23
- const globalStore = (globalThis as any)[globalStoreId] as Map<unknown, any>
19
+ let globalStore: Map<unknown, any>
24
20
 
25
21
  /**
26
22
  * Retrieves or computes a global value associated with the given `id`. If the value for this `id`
@@ -46,6 +42,12 @@ const globalStore = (globalThis as any)[globalStoreId] as Map<unknown, any>
46
42
  * @since 2.0.0
47
43
  */
48
44
  export const globalValue = <A>(id: unknown, compute: () => A): A => {
45
+ if (!globalStore) {
46
+ // @ts-expect-error
47
+ globalThis[globalStoreId] ??= new Map()
48
+ // @ts-expect-error
49
+ globalStore = globalThis[globalStoreId] as Map<unknown, any>
50
+ }
49
51
  if (!globalStore.has(id)) {
50
52
  globalStore.set(id, compute())
51
53
  }
package/src/HashMap.ts CHANGED
@@ -6,7 +6,7 @@ import type { Equal } from "./Equal.js"
6
6
  import type { HashSet } from "./HashSet.js"
7
7
  import type { Inspectable } from "./Inspectable.js"
8
8
  import * as HM from "./internal/hashMap.js"
9
- import * as _keySet from "./internal/hashMap/keySet.js"
9
+ import * as keySet_ from "./internal/hashMap/keySet.js"
10
10
  import type { Option } from "./Option.js"
11
11
  import type { Pipeable } from "./Pipeable.js"
12
12
  import type { NoInfer } from "./Types.js"
@@ -305,7 +305,7 @@ export const keys: <K, V>(self: HashMap<K, V>) => IterableIterator<K> = HM.keys
305
305
  * @since 2.0.0
306
306
  * @category getter
307
307
  */
308
- export const keySet: <K, V>(self: HashMap<K, V>) => HashSet<K> = _keySet.keySet
308
+ export const keySet: <K, V>(self: HashMap<K, V>) => HashSet<K> = keySet_.keySet
309
309
 
310
310
  /**
311
311
  * Returns an `IterableIterator` of the values within the `HashMap`.
package/src/Layer.ts CHANGED
@@ -82,9 +82,9 @@ export declare namespace Layer {
82
82
  */
83
83
  export interface Any {
84
84
  readonly [LayerTypeId]: {
85
- readonly _ROut: any
86
- readonly _E: any
87
- readonly _RIn: any
85
+ readonly _ROut: Types.Contravariant<never>
86
+ readonly _E: Types.Covariant<any>
87
+ readonly _RIn: Types.Covariant<any>
88
88
  }
89
89
  }
90
90
  /**
@@ -40,12 +40,13 @@ export declare namespace ManagedRuntime {
40
40
  * @category type-level
41
41
  * @since 3.4.0
42
42
  */
43
- export type Context<T extends ManagedRuntime<any, any>> = [T] extends [ManagedRuntime<infer R, infer _E>] ? R : never
43
+ export type Context<T extends ManagedRuntime<never, any>> = [T] extends [ManagedRuntime<infer R, infer _E>] ? R
44
+ : never
44
45
  /**
45
46
  * @category type-level
46
47
  * @since 3.4.0
47
48
  */
48
- export type Error<T extends ManagedRuntime<any, any>> = [T] extends [ManagedRuntime<infer _R, infer E>] ? E : never
49
+ export type Error<T extends ManagedRuntime<never, any>> = [T] extends [ManagedRuntime<infer _R, infer E>] ? E : never
49
50
  }
50
51
 
51
52
  /**
package/src/Predicate.ts CHANGED
@@ -43,7 +43,7 @@ export declare namespace Predicate {
43
43
  * @since 3.6.0
44
44
  * @category type-level
45
45
  */
46
- export type Any = Predicate<any>
46
+ export type Any = Predicate<never>
47
47
  }
48
48
 
49
49
  /**
@@ -1080,7 +1080,7 @@ export const struct: {
1080
1080
  const keys = Object.keys(fields)
1081
1081
  return (a: Record<string, unknown>) => {
1082
1082
  for (const key of keys) {
1083
- if (!fields[key](a[key])) {
1083
+ if (!fields[key](a[key] as never)) {
1084
1084
  return false
1085
1085
  }
1086
1086
  }
package/src/Request.ts CHANGED
@@ -8,7 +8,7 @@ import type { DurationInput } from "./Duration.js"
8
8
  import type * as Effect from "./Effect.js"
9
9
  import type * as Exit from "./Exit.js"
10
10
  import type { FiberId } from "./FiberId.js"
11
- import * as _RequestBlock from "./internal/blockedRequests.js"
11
+ import * as RequestBlock_ from "./internal/blockedRequests.js"
12
12
  import * as cache from "./internal/cache.js"
13
13
  import * as core from "./internal/core.js"
14
14
  import * as fiberRuntime from "./internal/fiberRuntime.js"
@@ -414,10 +414,10 @@ export declare namespace Entry {
414
414
  * @since 2.0.0
415
415
  * @category guards
416
416
  */
417
- export const isEntry = _RequestBlock.isEntry
417
+ export const isEntry = RequestBlock_.isEntry
418
418
 
419
419
  /**
420
420
  * @since 2.0.0
421
421
  * @category constructors
422
422
  */
423
- export const makeEntry = _RequestBlock.makeEntry
423
+ export const makeEntry = RequestBlock_.makeEntry
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @since 2.0.0
3
3
  */
4
- import * as _RequestBlock from "./internal/blockedRequests.js"
4
+ import * as RequestBlock_ from "./internal/blockedRequests.js"
5
5
  import type * as Request from "./Request.js"
6
6
  import type * as RequestResolver from "./RequestResolver.js"
7
7
 
@@ -82,13 +82,13 @@ export interface Single {
82
82
  export const single: <A>(
83
83
  dataSource: RequestResolver.RequestResolver<A>,
84
84
  blockedRequest: Request.Entry<A>
85
- ) => RequestBlock = _RequestBlock.single
85
+ ) => RequestBlock = RequestBlock_.single
86
86
 
87
87
  /**
88
88
  * @since 2.0.0
89
89
  * @category constructors
90
90
  */
91
- export const empty: RequestBlock = _RequestBlock.empty
91
+ export const empty: RequestBlock = RequestBlock_.empty
92
92
 
93
93
  /**
94
94
  * @since 2.0.0
@@ -97,22 +97,22 @@ export const empty: RequestBlock = _RequestBlock.empty
97
97
  export const mapRequestResolvers: <A>(
98
98
  self: RequestBlock,
99
99
  f: (dataSource: RequestResolver.RequestResolver<A>) => RequestResolver.RequestResolver<A>
100
- ) => RequestBlock = _RequestBlock.mapRequestResolvers
100
+ ) => RequestBlock = RequestBlock_.mapRequestResolvers
101
101
 
102
102
  /**
103
103
  * @since 2.0.0
104
104
  * @category constructors
105
105
  */
106
- export const parallel: (self: RequestBlock, that: RequestBlock) => RequestBlock = _RequestBlock.par
106
+ export const parallel: (self: RequestBlock, that: RequestBlock) => RequestBlock = RequestBlock_.par
107
107
 
108
108
  /**
109
109
  * @since 2.0.0
110
110
  * @category constructors
111
111
  */
112
- export const reduce: <Z>(self: RequestBlock, reducer: RequestBlock.Reducer<Z>) => Z = _RequestBlock.reduce
112
+ export const reduce: <Z>(self: RequestBlock, reducer: RequestBlock.Reducer<Z>) => Z = RequestBlock_.reduce
113
113
 
114
114
  /**
115
115
  * @since 2.0.0
116
116
  * @category constructors
117
117
  */
118
- export const sequential: (self: RequestBlock, that: RequestBlock) => RequestBlock = _RequestBlock.seq
118
+ export const sequential: (self: RequestBlock, that: RequestBlock) => RequestBlock = RequestBlock_.seq
package/src/Runtime.ts CHANGED
@@ -60,7 +60,7 @@ export declare namespace Runtime {
60
60
  * @since 3.12.0
61
61
  * @category Type Extractors
62
62
  */
63
- export type Context<T extends Runtime<any>> = [T] extends [Runtime<infer R>] ? R : never
63
+ export type Context<T extends Runtime<never>> = [T] extends [Runtime<infer R>] ? R : never
64
64
  }
65
65
 
66
66
  /**
@@ -128,10 +128,7 @@ export interface RunCallbackOptions<in A, in E = never> extends RunForkOptions {
128
128
  */
129
129
  export const runCallback: <R>(
130
130
  runtime: Runtime<R>
131
- ) => <A, E>(
132
- effect: Effect.Effect<A, E, R>,
133
- options?: RunCallbackOptions<A, E> | undefined
134
- ) => (fiberId?: FiberId.FiberId | undefined, options?: RunCallbackOptions<A, E> | undefined) => void =
131
+ ) => <A, E>(effect: Effect.Effect<A, E, R>, options?: RunCallbackOptions<A, E> | undefined) => Cancel<A, E> =
135
132
  internal.unsafeRunCallback
136
133
 
137
134
  /**
package/src/Schema.ts CHANGED
@@ -102,10 +102,6 @@ export interface SchemaClass<A, I = A, R = never> extends AnnotableClass<SchemaC
102
102
  */
103
103
  export const make = <A, I = A, R = never>(ast: AST.AST): SchemaClass<A, I, R> => (class SchemaClass {
104
104
  [TypeId] = variance
105
- static Type: A
106
- static Encoded: I
107
- static Context: R
108
- static [TypeId] = variance
109
105
  static ast = ast
110
106
  static annotations(annotations: Annotations.GenericSchema<A>) {
111
107
  return make<A, I, R>(mergeSchemaAnnotations(this.ast, annotations))
@@ -116,6 +112,10 @@ export const make = <A, I = A, R = never>(ast: AST.AST): SchemaClass<A, I, R> =>
116
112
  static toString() {
117
113
  return String(ast)
118
114
  }
115
+ static Type: A
116
+ static Encoded: I
117
+ static Context: R
118
+ static [TypeId] = variance
119
119
  })
120
120
 
121
121
  const variance = {
@@ -7418,10 +7418,7 @@ export const OptionFromUndefinedOr = <Value extends Schema.Any>(
7418
7418
  */
7419
7419
  export const OptionFromNonEmptyTrimmedString = transform(String$, OptionFromSelf(NonEmptyTrimmedString), {
7420
7420
  strict: true,
7421
- decode: (s) => {
7422
- const out = s.trim()
7423
- return out.length === 0 ? option_.none() : option_.some(out)
7424
- },
7421
+ decode: (s) => option_.filter(option_.some(s.trim()), string_.isNonEmpty),
7425
7422
  encode: option_.getOrElse(() => "")
7426
7423
  })
7427
7424
 
package/src/Stream.ts CHANGED
@@ -13,7 +13,7 @@ import type * as Exit from "./Exit.js"
13
13
  import type { LazyArg } from "./Function.js"
14
14
  import type * as GroupBy from "./GroupBy.js"
15
15
  import type { TypeLambda } from "./HKT.js"
16
- import * as _groupBy from "./internal/groupBy.js"
16
+ import * as groupBy_ from "./internal/groupBy.js"
17
17
  import * as internal from "./internal/stream.js"
18
18
  import type * as Layer from "./Layer.js"
19
19
  import type * as Option from "./Option.js"
@@ -3754,7 +3754,7 @@ export const groupBy: {
3754
3754
  f: (a: A) => Effect.Effect<readonly [K, V], E2, R2>,
3755
3755
  options?: { readonly bufferSize?: number | undefined } | undefined
3756
3756
  ): GroupBy.GroupBy<K, V, E | E2, R | R2>
3757
- } = _groupBy.groupBy
3757
+ } = groupBy_.groupBy
3758
3758
 
3759
3759
  /**
3760
3760
  * Partition a stream using a function and process each stream individually.
@@ -3881,7 +3881,7 @@ export const groupByKey: {
3881
3881
  readonly bufferSize?: number | undefined
3882
3882
  }
3883
3883
  ): GroupBy.GroupBy<K, A, E, R>
3884
- } = _groupBy.groupByKey
3884
+ } = groupBy_.groupByKey
3885
3885
 
3886
3886
  /**
3887
3887
  * Partitions the stream with specified `chunkSize`.
@@ -5208,7 +5208,7 @@ export const mapEffect: {
5208
5208
  f: (a: A) => Effect.Effect<A2, E2, R2>,
5209
5209
  options: { readonly key: (a: A) => K; readonly bufferSize?: number | undefined }
5210
5210
  ): Stream<A2, E | E2, R | R2>
5211
- } = _groupBy.mapEffectOptions
5211
+ } = groupBy_.mapEffectOptions
5212
5212
 
5213
5213
  /**
5214
5214
  * Transforms the errors emitted by this stream using `f`.
@@ -11453,7 +11453,7 @@ export const bindEffect: {
11453
11453
  f: (_: NoInfer<A>) => Effect.Effect<B, E2, R2>,
11454
11454
  options?: { readonly concurrency?: number | "unbounded" | undefined; readonly unordered?: boolean | undefined }
11455
11455
  ): Stream<{ [K in keyof A | N]: K extends keyof A ? A[K] : B }, E | E2, R | R2>
11456
- } = _groupBy.bindEffect
11456
+ } = groupBy_.bindEffect
11457
11457
 
11458
11458
  /**
11459
11459
  * The "do simulation" in Effect 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`.
package/src/Utils.ts CHANGED
@@ -40,7 +40,7 @@ export type GenKindTypeId = typeof GenKindTypeId
40
40
  export interface GenKind<F extends TypeLambda, R, O, E, A> extends Variance<F, R, O, E> {
41
41
  readonly value: Kind<F, R, O, E, A>
42
42
 
43
- [Symbol.iterator](): Generator<GenKind<F, R, O, E, A>, A>
43
+ [Symbol.iterator](): IterableIterator<GenKind<F, R, O, E, A>, A>
44
44
  }
45
45
 
46
46
  /**
@@ -97,7 +97,7 @@ export class GenKindImpl<F extends TypeLambda, R, O, E, A> implements GenKind<F,
97
97
  /**
98
98
  * @since 2.0.0
99
99
  */
100
- [Symbol.iterator](): Generator<GenKind<F, R, O, E, A>, A> {
100
+ [Symbol.iterator](): IterableIterator<GenKind<F, R, O, E, A>, A> {
101
101
  return new SingleShotGen<GenKind<F, R, O, E, A>, A>(this as any)
102
102
  }
103
103
  }
@@ -106,7 +106,7 @@ export class GenKindImpl<F extends TypeLambda, R, O, E, A> implements GenKind<F,
106
106
  * @category constructors
107
107
  * @since 2.0.0
108
108
  */
109
- export class SingleShotGen<T, A> implements Generator<T, A> {
109
+ export class SingleShotGen<T, A> implements IterableIterator<T, A> {
110
110
  private called = false
111
111
 
112
112
  constructor(readonly self: T) {}
@@ -147,7 +147,7 @@ export class SingleShotGen<T, A> implements Generator<T, A> {
147
147
  /**
148
148
  * @since 2.0.0
149
149
  */
150
- [Symbol.iterator](): Generator<T, A> {
150
+ [Symbol.iterator](): IterableIterator<T, A> {
151
151
  return new SingleShotGen<T, A>(this.self)
152
152
  }
153
153
  }
@@ -27,7 +27,7 @@ import * as executor from "./channel/channelExecutor.js"
27
27
  import type * as ChannelState from "./channel/channelState.js"
28
28
  import * as mergeDecision from "./channel/mergeDecision.js"
29
29
  import * as mergeState from "./channel/mergeState.js"
30
- import * as _mergeStrategy from "./channel/mergeStrategy.js"
30
+ import * as mergeStrategy_ from "./channel/mergeStrategy.js"
31
31
  import * as singleProducerAsyncInput from "./channel/singleProducerAsyncInput.js"
32
32
  import * as coreEffect from "./core-effect.js"
33
33
  import * as core from "./core-stream.js"
@@ -1086,7 +1086,7 @@ export const mergeAllWith = (
1086
1086
  {
1087
1087
  bufferSize = 16,
1088
1088
  concurrency,
1089
- mergeStrategy = _mergeStrategy.BackPressure()
1089
+ mergeStrategy = mergeStrategy_.BackPressure()
1090
1090
  }: {
1091
1091
  readonly concurrency: number | "unbounded"
1092
1092
  readonly bufferSize?: number | undefined
@@ -1198,7 +1198,7 @@ export const mergeAllWith = (
1198
1198
  }
1199
1199
  ),
1200
1200
  onRight: (channel) =>
1201
- _mergeStrategy.match(mergeStrategy, {
1201
+ mergeStrategy_.match(mergeStrategy, {
1202
1202
  onBackPressure: () =>
1203
1203
  Effect.gen(function*() {
1204
1204
  const latch = yield* Deferred.make<void>()
@@ -99,13 +99,11 @@ export const try_: {
99
99
  evaluate = arg.try
100
100
  onFailure = arg.catch
101
101
  }
102
- return core.sync(() => {
102
+ return core.suspend(() => {
103
103
  try {
104
- return evaluate()
104
+ return core.succeed(internalCall(evaluate))
105
105
  } catch (error) {
106
- throw core.makeEffectError(internalCause.fail(
107
- onFailure ? onFailure(error) : new core.UnknownException(error)
108
- ))
106
+ return core.fail(onFailure ? internalCall(() => onFailure(error)) : new core.UnknownException(error))
109
107
  }
110
108
  })
111
109
  }
@@ -1600,7 +1598,7 @@ export const tapErrorCause = dual<
1600
1598
  /* @internal */
1601
1599
  export const timed = <A, E, R>(
1602
1600
  self: Effect.Effect<A, E, R>
1603
- ): Effect.Effect<[Duration.Duration, A], E, R> => timedWith(self, Clock.currentTimeNanos)
1601
+ ): Effect.Effect<[duration: Duration.Duration, result: A], E, R> => timedWith(self, Clock.currentTimeNanos)
1604
1602
 
1605
1603
  /* @internal */
1606
1604
  export const timedWith = dual<
@@ -38,7 +38,7 @@ import type * as Scope from "../Scope.js"
38
38
  import type * as Tracer from "../Tracer.js"
39
39
  import type { NoInfer, NotFunction } from "../Types.js"
40
40
  import { internalCall, YieldWrap } from "../Utils.js"
41
- import * as _blockedRequests from "./blockedRequests.js"
41
+ import * as blockedRequests_ from "./blockedRequests.js"
42
42
  import * as internalCause from "./cause.js"
43
43
  import * as deferred from "./deferred.js"
44
44
  import * as internalDiffer from "./differ.js"
@@ -48,39 +48,13 @@ import type * as FiberRuntime from "./fiberRuntime.js"
48
48
  import type * as fiberScope from "./fiberScope.js"
49
49
  import * as DeferredOpCodes from "./opCodes/deferred.js"
50
50
  import * as OpCodes from "./opCodes/effect.js"
51
- import * as _runtimeFlags from "./runtimeFlags.js"
51
+ import * as runtimeFlags_ from "./runtimeFlags.js"
52
52
  import { SingleShotGen } from "./singleShotGen.js"
53
53
 
54
54
  // -----------------------------------------------------------------------------
55
55
  // Effect
56
56
  // -----------------------------------------------------------------------------
57
57
 
58
- /** @internal */
59
- const EffectErrorSymbolKey = "effect/EffectError"
60
-
61
- /** @internal */
62
- export const EffectErrorTypeId = Symbol.for(EffectErrorSymbolKey)
63
-
64
- /** @internal */
65
- export type EffectErrorTypeId = typeof EffectErrorTypeId
66
-
67
- /** @internal */
68
- export interface EffectError<out E> {
69
- readonly [EffectErrorTypeId]: EffectErrorTypeId
70
- readonly _tag: "EffectError"
71
- readonly cause: Cause.Cause<E>
72
- }
73
-
74
- /** @internal */
75
- export const isEffectError = (u: unknown): u is EffectError<unknown> => hasProperty(u, EffectErrorTypeId)
76
-
77
- /** @internal */
78
- export const makeEffectError = <E>(cause: Cause.Cause<E>): EffectError<E> => ({
79
- [EffectErrorTypeId]: EffectErrorTypeId,
80
- _tag: "EffectError",
81
- cause
82
- })
83
-
84
58
  /**
85
59
  * @internal
86
60
  */
@@ -677,7 +651,7 @@ export const catchSome = dual<
677
651
  /* @internal */
678
652
  export const checkInterruptible = <A, E, R>(
679
653
  f: (isInterruptible: boolean) => Effect.Effect<A, E, R>
680
- ): Effect.Effect<A, E, R> => withFiberRuntime((_, status) => f(_runtimeFlags.interruption(status.runtimeFlags)))
654
+ ): Effect.Effect<A, E, R> => withFiberRuntime((_, status) => f(runtimeFlags_.interruption(status.runtimeFlags)))
681
655
 
682
656
  const spanSymbol = Symbol.for("effect/SpanAnnotation")
683
657
  const originalSymbol = Symbol.for("effect/OriginalAnnotation")
@@ -1027,7 +1001,7 @@ export const interruptWith = (fiberId: FiberId.FiberId): Effect.Effect<never> =>
1027
1001
  /* @internal */
1028
1002
  export const interruptible = <A, E, R>(self: Effect.Effect<A, E, R>): Effect.Effect<A, E, R> => {
1029
1003
  const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS) as any
1030
- effect.effect_instruction_i0 = RuntimeFlagsPatch.enable(_runtimeFlags.Interruption)
1004
+ effect.effect_instruction_i0 = RuntimeFlagsPatch.enable(runtimeFlags_.Interruption)
1031
1005
  effect.effect_instruction_i1 = () => self
1032
1006
  return effect
1033
1007
  }
@@ -1038,9 +1012,9 @@ export const interruptibleMask = <A, E, R>(
1038
1012
  ): Effect.Effect<A, E, R> =>
1039
1013
  custom(f, function() {
1040
1014
  const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS) as any
1041
- effect.effect_instruction_i0 = RuntimeFlagsPatch.enable(_runtimeFlags.Interruption)
1015
+ effect.effect_instruction_i0 = RuntimeFlagsPatch.enable(runtimeFlags_.Interruption)
1042
1016
  effect.effect_instruction_i1 = (oldFlags: RuntimeFlags.RuntimeFlags) =>
1043
- _runtimeFlags.interruption(oldFlags)
1017
+ runtimeFlags_.interruption(oldFlags)
1044
1018
  ? internalCall(() => this.effect_instruction_i0(interruptible))
1045
1019
  : internalCall(() => this.effect_instruction_i0(uninterruptible))
1046
1020
  return effect
@@ -1356,7 +1330,7 @@ export const uninterruptible: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.
1356
1330
  self: Effect.Effect<A, E, R>
1357
1331
  ): Effect.Effect<A, E, R> => {
1358
1332
  const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS) as any
1359
- effect.effect_instruction_i0 = RuntimeFlagsPatch.disable(_runtimeFlags.Interruption)
1333
+ effect.effect_instruction_i0 = RuntimeFlagsPatch.disable(runtimeFlags_.Interruption)
1360
1334
  effect.effect_instruction_i1 = () => self
1361
1335
  return effect
1362
1336
  }
@@ -1367,9 +1341,9 @@ export const uninterruptibleMask = <A, E, R>(
1367
1341
  ): Effect.Effect<A, E, R> =>
1368
1342
  custom(f, function() {
1369
1343
  const effect = new EffectPrimitive(OpCodes.OP_UPDATE_RUNTIME_FLAGS) as any
1370
- effect.effect_instruction_i0 = RuntimeFlagsPatch.disable(_runtimeFlags.Interruption)
1344
+ effect.effect_instruction_i0 = RuntimeFlagsPatch.disable(runtimeFlags_.Interruption)
1371
1345
  effect.effect_instruction_i1 = (oldFlags: RuntimeFlags.RuntimeFlags) =>
1372
- _runtimeFlags.interruption(oldFlags)
1346
+ runtimeFlags_.interruption(oldFlags)
1373
1347
  ? internalCall(() => this.effect_instruction_i0(interruptible))
1374
1348
  : internalCall(() => this.effect_instruction_i0(uninterruptible))
1375
1349
  return effect
@@ -1904,17 +1878,17 @@ export const requestBlockLocally = <A>(
1904
1878
  self: BlockedRequests.RequestBlock,
1905
1879
  ref: FiberRef.FiberRef<A>,
1906
1880
  value: A
1907
- ): BlockedRequests.RequestBlock => _blockedRequests.reduce(self, LocallyReducer(ref, value))
1881
+ ): BlockedRequests.RequestBlock => blockedRequests_.reduce(self, LocallyReducer(ref, value))
1908
1882
 
1909
1883
  const LocallyReducer = <A>(
1910
1884
  ref: FiberRef.FiberRef<A>,
1911
1885
  value: A
1912
1886
  ): BlockedRequests.RequestBlock.Reducer<BlockedRequests.RequestBlock> => ({
1913
- emptyCase: () => _blockedRequests.empty,
1914
- parCase: (left, right) => _blockedRequests.par(left, right),
1915
- seqCase: (left, right) => _blockedRequests.seq(left, right),
1887
+ emptyCase: () => blockedRequests_.empty,
1888
+ parCase: (left, right) => blockedRequests_.par(left, right),
1889
+ seqCase: (left, right) => blockedRequests_.seq(left, right),
1916
1890
  singleCase: (dataSource, blockedRequest) =>
1917
- _blockedRequests.single(
1891
+ blockedRequests_.single(
1918
1892
  resolverLocally(dataSource, ref, value),
1919
1893
  blockedRequest as any
1920
1894
  )
@@ -2017,8 +1991,8 @@ export const fiberRefUnsafeMakeRuntimeFlags = (
2017
1991
  initial: RuntimeFlags.RuntimeFlags
2018
1992
  ): FiberRef.FiberRef<RuntimeFlags.RuntimeFlags> =>
2019
1993
  fiberRefUnsafeMakePatch(initial, {
2020
- differ: _runtimeFlags.differ,
2021
- fork: _runtimeFlags.differ.empty
1994
+ differ: runtimeFlags_.differ,
1995
+ fork: runtimeFlags_.differ.empty
2022
1996
  })
2023
1997
 
2024
1998
  /** @internal */
@@ -3024,9 +2998,9 @@ export const contextWith = <R0, A>(
3024
2998
  ): Effect.Effect<A, never, R0> => map(context<R0>(), f)
3025
2999
 
3026
3000
  /* @internal */
3027
- export const contextWithEffect = <R0, A, E, R>(
3028
- f: (context: Context.Context<R0>) => Effect.Effect<A, E, R>
3029
- ): Effect.Effect<A, E, R | R0> => flatMap(context<R0>(), f)
3001
+ export const contextWithEffect = <R2, A, E, R>(
3002
+ f: (context: Context.Context<R2>) => Effect.Effect<A, E, R>
3003
+ ): Effect.Effect<A, E, R | R2> => flatMap(context<R2>(), f)
3030
3004
 
3031
3005
  /* @internal */
3032
3006
  export const provideContext = dual<
@@ -3050,17 +3024,17 @@ export const provideSomeContext = dual<
3050
3024
 
3051
3025
  /* @internal */
3052
3026
  export const mapInputContext = dual<
3053
- <R0, R>(
3054
- f: (context: Context.Context<R0>) => Context.Context<R>
3055
- ) => <A, E>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R0>,
3056
- <A, E, R, R0>(
3027
+ <R2, R>(
3028
+ f: (context: Context.Context<R2>) => Context.Context<R>
3029
+ ) => <A, E>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R2>,
3030
+ <A, E, R, R2>(
3057
3031
  self: Effect.Effect<A, E, R>,
3058
- f: (context: Context.Context<R0>) => Context.Context<R>
3059
- ) => Effect.Effect<A, E, R0>
3060
- >(2, <A, E, R, R0>(
3032
+ f: (context: Context.Context<R2>) => Context.Context<R>
3033
+ ) => Effect.Effect<A, E, R2>
3034
+ >(2, <A, E, R, R2>(
3061
3035
  self: Effect.Effect<A, E, R>,
3062
- f: (context: Context.Context<R0>) => Context.Context<R>
3063
- ) => contextWithEffect((context: Context.Context<R0>) => provideContext(self, f(context))))
3036
+ f: (context: Context.Context<R2>) => Context.Context<R>
3037
+ ) => contextWithEffect((context: Context.Context<R2>) => provideContext(self, f(context))))
3064
3038
 
3065
3039
  // -----------------------------------------------------------------------------
3066
3040
  // Tracing
@@ -64,29 +64,29 @@ export const currentTimeNanos: Effect.Effect<bigint> = clockWith((clock) => cloc
64
64
 
65
65
  /** @internal */
66
66
  export const withClock = dual<
67
- <X extends Clock.Clock>(value: X) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>,
68
- <X extends Clock.Clock, A, E, R>(effect: Effect.Effect<A, E, R>, value: X) => Effect.Effect<A, E, R>
69
- >(2, (effect, value) =>
67
+ <C extends Clock.Clock>(clock: C) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>,
68
+ <C extends Clock.Clock, A, E, R>(effect: Effect.Effect<A, E, R>, clock: C) => Effect.Effect<A, E, R>
69
+ >(2, (effect, c) =>
70
70
  core.fiberRefLocallyWith(
71
71
  currentServices,
72
- Context.add(clock.clockTag, value)
72
+ Context.add(clock.clockTag, c)
73
73
  )(effect))
74
74
 
75
75
  // circular with ConfigProvider
76
76
 
77
77
  /** @internal */
78
78
  export const withConfigProvider = dual<
79
- (value: ConfigProvider.ConfigProvider) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>,
80
- <A, E, R>(effect: Effect.Effect<A, E, R>, value: ConfigProvider.ConfigProvider) => Effect.Effect<A, E, R>
81
- >(2, (effect, value) =>
79
+ (provider: ConfigProvider.ConfigProvider) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>,
80
+ <A, E, R>(self: Effect.Effect<A, E, R>, provider: ConfigProvider.ConfigProvider) => Effect.Effect<A, E, R>
81
+ >(2, (self, provider) =>
82
82
  core.fiberRefLocallyWith(
83
83
  currentServices,
84
- Context.add(configProvider.configProviderTag, value)
85
- )(effect))
84
+ Context.add(configProvider.configProviderTag, provider)
85
+ )(self))
86
86
 
87
87
  /** @internal */
88
88
  export const configProviderWith = <A, E, R>(
89
- f: (configProvider: ConfigProvider.ConfigProvider) => Effect.Effect<A, E, R>
89
+ f: (provider: ConfigProvider.ConfigProvider) => Effect.Effect<A, E, R>
90
90
  ): Effect.Effect<A, E, R> =>
91
91
  defaultServicesWith((services) => f(services.unsafeMap.get(configProvider.configProviderTag.key)))
92
92