effect 3.0.4 → 3.0.6

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 (162) hide show
  1. package/dist/cjs/Array.js.map +1 -1
  2. package/dist/cjs/Effect.js.map +1 -1
  3. package/dist/cjs/Either.js +14 -2
  4. package/dist/cjs/Either.js.map +1 -1
  5. package/dist/cjs/Exit.js.map +1 -1
  6. package/dist/cjs/HashMap.js.map +1 -1
  7. package/dist/cjs/HashSet.js.map +1 -1
  8. package/dist/cjs/Iterable.js.map +1 -1
  9. package/dist/cjs/List.js.map +1 -1
  10. package/dist/cjs/Option.js +13 -1
  11. package/dist/cjs/Option.js.map +1 -1
  12. package/dist/cjs/Readable.js.map +1 -1
  13. package/dist/cjs/Record.js.map +1 -1
  14. package/dist/cjs/RequestResolver.js.map +1 -1
  15. package/dist/cjs/STM.js.map +1 -1
  16. package/dist/cjs/Subscribable.js.map +1 -1
  17. package/dist/cjs/Utils.js +42 -2
  18. package/dist/cjs/Utils.js.map +1 -1
  19. package/dist/cjs/internal/cause.js.map +1 -1
  20. package/dist/cjs/internal/core-effect.js +4 -1
  21. package/dist/cjs/internal/core-effect.js.map +1 -1
  22. package/dist/cjs/internal/core.js +4 -3
  23. package/dist/cjs/internal/core.js.map +1 -1
  24. package/dist/cjs/internal/dataSource.js +2 -2
  25. package/dist/cjs/internal/dataSource.js.map +1 -1
  26. package/dist/cjs/internal/effectable.js +2 -2
  27. package/dist/cjs/internal/effectable.js.map +1 -1
  28. package/dist/cjs/internal/fiberRuntime.js.map +1 -1
  29. package/dist/cjs/internal/hashMap.js.map +1 -1
  30. package/dist/cjs/internal/hashSet.js.map +1 -1
  31. package/dist/cjs/internal/schedule.js.map +1 -1
  32. package/dist/cjs/internal/stm/core.js +2 -1
  33. package/dist/cjs/internal/stm/core.js.map +1 -1
  34. package/dist/cjs/internal/stm/stm.js +2 -1
  35. package/dist/cjs/internal/stm/stm.js.map +1 -1
  36. package/dist/cjs/internal/trie.js.map +1 -1
  37. package/dist/cjs/internal/version.js +1 -1
  38. package/dist/dts/Array.d.ts +1 -0
  39. package/dist/dts/Array.d.ts.map +1 -1
  40. package/dist/dts/Cause.d.ts +2 -2
  41. package/dist/dts/Cause.d.ts.map +1 -1
  42. package/dist/dts/Chunk.d.ts +1 -1
  43. package/dist/dts/Chunk.d.ts.map +1 -1
  44. package/dist/dts/Effect.d.ts +18 -14
  45. package/dist/dts/Effect.d.ts.map +1 -1
  46. package/dist/dts/Either.d.ts +2 -2
  47. package/dist/dts/Either.d.ts.map +1 -1
  48. package/dist/dts/Exit.d.ts +1 -0
  49. package/dist/dts/Exit.d.ts.map +1 -1
  50. package/dist/dts/GroupBy.d.ts +1 -1
  51. package/dist/dts/GroupBy.d.ts.map +1 -1
  52. package/dist/dts/HashMap.d.ts +1 -0
  53. package/dist/dts/HashMap.d.ts.map +1 -1
  54. package/dist/dts/HashSet.d.ts +1 -0
  55. package/dist/dts/HashSet.d.ts.map +1 -1
  56. package/dist/dts/Iterable.d.ts +1 -0
  57. package/dist/dts/Iterable.d.ts.map +1 -1
  58. package/dist/dts/List.d.ts +1 -0
  59. package/dist/dts/List.d.ts.map +1 -1
  60. package/dist/dts/Logger.d.ts +2 -2
  61. package/dist/dts/Logger.d.ts.map +1 -1
  62. package/dist/dts/Option.d.ts +2 -2
  63. package/dist/dts/Option.d.ts.map +1 -1
  64. package/dist/dts/Readable.d.ts +1 -0
  65. package/dist/dts/Readable.d.ts.map +1 -1
  66. package/dist/dts/Record.d.ts +1 -0
  67. package/dist/dts/Record.d.ts.map +1 -1
  68. package/dist/dts/RequestResolver.d.ts +5 -4
  69. package/dist/dts/RequestResolver.d.ts.map +1 -1
  70. package/dist/dts/STM.d.ts +5 -4
  71. package/dist/dts/STM.d.ts.map +1 -1
  72. package/dist/dts/SortedSet.d.ts +1 -1
  73. package/dist/dts/SortedSet.d.ts.map +1 -1
  74. package/dist/dts/Stream.d.ts +1 -1
  75. package/dist/dts/Stream.d.ts.map +1 -1
  76. package/dist/dts/Subscribable.d.ts +1 -0
  77. package/dist/dts/Subscribable.d.ts.map +1 -1
  78. package/dist/dts/Trie.d.ts +1 -1
  79. package/dist/dts/Trie.d.ts.map +1 -1
  80. package/dist/dts/Types.d.ts +7 -0
  81. package/dist/dts/Types.d.ts.map +1 -1
  82. package/dist/dts/Utils.d.ts +49 -25
  83. package/dist/dts/Utils.d.ts.map +1 -1
  84. package/dist/dts/internal/core.d.ts.map +1 -1
  85. package/dist/dts/internal/hashMap.d.ts.map +1 -1
  86. package/dist/dts/internal/stm/stm.d.ts.map +1 -1
  87. package/dist/esm/Array.js.map +1 -1
  88. package/dist/esm/Effect.js.map +1 -1
  89. package/dist/esm/Either.js +14 -2
  90. package/dist/esm/Either.js.map +1 -1
  91. package/dist/esm/Exit.js.map +1 -1
  92. package/dist/esm/HashMap.js.map +1 -1
  93. package/dist/esm/HashSet.js.map +1 -1
  94. package/dist/esm/Iterable.js.map +1 -1
  95. package/dist/esm/List.js.map +1 -1
  96. package/dist/esm/Option.js +14 -2
  97. package/dist/esm/Option.js.map +1 -1
  98. package/dist/esm/Readable.js.map +1 -1
  99. package/dist/esm/Record.js.map +1 -1
  100. package/dist/esm/RequestResolver.js.map +1 -1
  101. package/dist/esm/STM.js.map +1 -1
  102. package/dist/esm/Subscribable.js.map +1 -1
  103. package/dist/esm/Utils.js +39 -2
  104. package/dist/esm/Utils.js.map +1 -1
  105. package/dist/esm/internal/cause.js.map +1 -1
  106. package/dist/esm/internal/core-effect.js +4 -1
  107. package/dist/esm/internal/core-effect.js.map +1 -1
  108. package/dist/esm/internal/core.js +4 -3
  109. package/dist/esm/internal/core.js.map +1 -1
  110. package/dist/esm/internal/dataSource.js +2 -2
  111. package/dist/esm/internal/dataSource.js.map +1 -1
  112. package/dist/esm/internal/effectable.js +2 -2
  113. package/dist/esm/internal/effectable.js.map +1 -1
  114. package/dist/esm/internal/fiberRuntime.js.map +1 -1
  115. package/dist/esm/internal/hashMap.js.map +1 -1
  116. package/dist/esm/internal/hashSet.js.map +1 -1
  117. package/dist/esm/internal/schedule.js.map +1 -1
  118. package/dist/esm/internal/stm/core.js +2 -1
  119. package/dist/esm/internal/stm/core.js.map +1 -1
  120. package/dist/esm/internal/stm/stm.js +2 -1
  121. package/dist/esm/internal/stm/stm.js.map +1 -1
  122. package/dist/esm/internal/trie.js.map +1 -1
  123. package/dist/esm/internal/version.js +1 -1
  124. package/package.json +1 -1
  125. package/src/Array.ts +1 -0
  126. package/src/Cause.ts +2 -2
  127. package/src/Chunk.ts +1 -1
  128. package/src/Effect.ts +28 -19
  129. package/src/Either.ts +17 -5
  130. package/src/Exit.ts +1 -0
  131. package/src/GroupBy.ts +1 -1
  132. package/src/HashMap.ts +1 -0
  133. package/src/HashSet.ts +1 -0
  134. package/src/Iterable.ts +1 -0
  135. package/src/List.ts +1 -0
  136. package/src/Logger.ts +2 -2
  137. package/src/Option.ts +17 -5
  138. package/src/Readable.ts +1 -0
  139. package/src/Record.ts +1 -0
  140. package/src/RequestResolver.ts +7 -6
  141. package/src/STM.ts +6 -5
  142. package/src/SortedSet.ts +1 -1
  143. package/src/Stream.ts +1 -1
  144. package/src/Subscribable.ts +1 -0
  145. package/src/Trie.ts +1 -1
  146. package/src/Types.ts +8 -0
  147. package/src/Utils.ts +75 -28
  148. package/src/internal/cause.ts +1 -0
  149. package/src/internal/core-effect.ts +7 -4
  150. package/src/internal/core.ts +5 -4
  151. package/src/internal/dataSource.ts +9 -8
  152. package/src/internal/effectable.ts +2 -2
  153. package/src/internal/fiberRuntime.ts +17 -6
  154. package/src/internal/groupBy.ts +1 -1
  155. package/src/internal/hashMap.ts +1 -0
  156. package/src/internal/hashSet.ts +1 -0
  157. package/src/internal/schedule.ts +6 -5
  158. package/src/internal/stm/core.ts +2 -1
  159. package/src/internal/stm/stm.ts +3 -2
  160. package/src/internal/stream.ts +1 -1
  161. package/src/internal/trie.ts +1 -0
  162. package/src/internal/version.ts +1 -1
@@ -2,6 +2,7 @@
2
2
  * @since 2.0.0
3
3
  */
4
4
 
5
+ import type { NonEmptyArray } from "./Array.js"
5
6
  import * as Context from "./Context.js"
6
7
  import * as Effect from "./Effect.js"
7
8
  import type * as Either from "./Either.js"
@@ -138,7 +139,7 @@ export const makeWithEntry: <A, R>(
138
139
  * @category constructors
139
140
  */
140
141
  export const makeBatched: <A extends Request.Request<any, any>, R>(
141
- run: (requests: Array<A>) => Effect.Effect<void, never, R>
142
+ run: (requests: NonEmptyArray<A>) => Effect.Effect<void, never, R>
142
143
  ) => RequestResolver<A, R> = internal.makeBatched
143
144
 
144
145
  /**
@@ -187,13 +188,13 @@ export const around: {
187
188
  */
188
189
  export const aroundRequests: {
189
190
  <A, A2, R2, X, R3>(
190
- before: (requests: ReadonlyArray<NoInfer<A>>) => Effect.Effect<A2, never, R2>,
191
- after: (requests: ReadonlyArray<NoInfer<A>>, _: A2) => Effect.Effect<X, never, R3>
191
+ before: (requests: ReadonlyArray<Types.NoInfer<A>>) => Effect.Effect<A2, never, R2>,
192
+ after: (requests: ReadonlyArray<Types.NoInfer<A>>, _: A2) => Effect.Effect<X, never, R3>
192
193
  ): <R>(self: RequestResolver<A, R>) => RequestResolver<A, R2 | R3 | R>
193
194
  <A, R, A2, R2, X, R3>(
194
195
  self: RequestResolver<A, R>,
195
- before: (requests: ReadonlyArray<NoInfer<A>>) => Effect.Effect<A2, never, R2>,
196
- after: (requests: ReadonlyArray<NoInfer<A>>, _: A2) => Effect.Effect<X, never, R3>
196
+ before: (requests: ReadonlyArray<Types.NoInfer<A>>) => Effect.Effect<A2, never, R2>,
197
+ after: (requests: ReadonlyArray<Types.NoInfer<A>>, _: A2) => Effect.Effect<X, never, R3>
197
198
  ): RequestResolver<A, R | R2 | R3>
198
199
  } = internal.aroundRequests
199
200
 
@@ -269,7 +270,7 @@ export const fromFunction: <A extends Request.Request<any>>(
269
270
  * @category constructors
270
271
  */
271
272
  export const fromFunctionBatched: <A extends Request.Request<any>>(
272
- f: (chunk: Array<A>) => Iterable<Request.Request.Success<A>>
273
+ f: (chunk: NonEmptyArray<A>) => Iterable<Request.Request.Success<A>>
273
274
  ) => RequestResolver<A> = internal.fromFunctionBatched
274
275
 
275
276
  /**
package/src/STM.ts CHANGED
@@ -14,8 +14,9 @@ import * as stm from "./internal/stm/stm.js"
14
14
  import type * as Option from "./Option.js"
15
15
  import type { Pipeable } from "./Pipeable.js"
16
16
  import type { Predicate, Refinement } from "./Predicate.js"
17
- import type { Covariant, MergeRecord } from "./Types.js"
17
+ import type { Covariant, MergeRecord, NoInfer } from "./Types.js"
18
18
  import type * as Unify from "./Unify.js"
19
+ import type { YieldWrap } from "./Utils.js"
19
20
 
20
21
  /**
21
22
  * @since 2.0.0
@@ -1064,12 +1065,12 @@ export interface Adapter {
1064
1065
  * @since 2.0.0
1065
1066
  * @category constructors
1066
1067
  */
1067
- export const gen: <Eff extends STM<any, any, any>, AEff>(
1068
- f: (resume: Adapter) => Generator<Eff, AEff, any>
1068
+ export const gen: <Eff extends YieldWrap<STM<any, any, any>>, AEff>(
1069
+ f: (resume: Adapter) => Generator<Eff, AEff, never>
1069
1070
  ) => STM<
1070
1071
  AEff,
1071
- [Eff] extends [never] ? never : [Eff] extends [STM<infer _A, infer E, infer _R>] ? E : never,
1072
- [Eff] extends [never] ? never : [Eff] extends [STM<infer _A, infer _E, infer R>] ? R : never
1072
+ [Eff] extends [never] ? never : [Eff] extends [YieldWrap<STM<infer _A, infer E, infer _R>>] ? E : never,
1073
+ [Eff] extends [never] ? never : [Eff] extends [YieldWrap<STM<infer _A, infer _E, infer R>>] ? R : never
1073
1074
  > = stm.gen
1074
1075
 
1075
1076
  /**
package/src/SortedSet.ts CHANGED
@@ -14,7 +14,7 @@ import { pipeArguments } from "./Pipeable.js"
14
14
  import type { Predicate } from "./Predicate.js"
15
15
  import { hasProperty } from "./Predicate.js"
16
16
  import * as RBT from "./RedBlackTree.js"
17
- import type { Invariant } from "./Types.js"
17
+ import type { Invariant, NoInfer } from "./Types.js"
18
18
 
19
19
  const TypeId: unique symbol = Symbol.for("effect/SortedSet")
20
20
 
package/src/Stream.ts CHANGED
@@ -29,7 +29,7 @@ import type * as Emit from "./StreamEmit.js"
29
29
  import type * as HaltStrategy from "./StreamHaltStrategy.js"
30
30
  import type * as Take from "./Take.js"
31
31
  import type * as Tracer from "./Tracer.js"
32
- import type { Covariant, MergeRecord } from "./Types.js"
32
+ import type { Covariant, MergeRecord, NoInfer } from "./Types.js"
33
33
  import type * as Unify from "./Unify.js"
34
34
 
35
35
  /**
@@ -7,6 +7,7 @@ import { pipeArguments } from "./Pipeable.js"
7
7
  import { hasProperty } from "./Predicate.js"
8
8
  import * as Readable from "./Readable.js"
9
9
  import * as Stream from "./Stream.js"
10
+ import type { NoInfer } from "./Types.js"
10
11
 
11
12
  /**
12
13
  * @since 2.0.0
package/src/Trie.ts CHANGED
@@ -20,7 +20,7 @@ import type { Inspectable } from "./Inspectable.js"
20
20
  import * as TR from "./internal/trie.js"
21
21
  import type { Option } from "./Option.js"
22
22
  import type { Pipeable } from "./Pipeable.js"
23
- import type { Covariant } from "./Types.js"
23
+ import type { Covariant, NoInfer } from "./Types.js"
24
24
 
25
25
  const TypeId: unique symbol = TR.TrieTypeId as TypeId
26
26
 
package/src/Types.ts CHANGED
@@ -170,6 +170,14 @@ export type Mutable<T> = {
170
170
  -readonly [P in keyof T]: T[P]
171
171
  }
172
172
 
173
+ /**
174
+ * Avoid inference on a specific parameter
175
+ *
176
+ * @since 2.0.0
177
+ * @category models
178
+ */
179
+ export type NoInfer<A> = [A][A extends any ? 0 : never]
180
+
173
181
  /**
174
182
  * Invariant helper.
175
183
  *
package/src/Utils.ts CHANGED
@@ -3,7 +3,8 @@
3
3
  */
4
4
  import { identity } from "./Function.js"
5
5
  import type { Kind, TypeLambda } from "./HKT.js"
6
- import { isNullable } from "./Predicate.js"
6
+ import { getBugErrorMessage } from "./internal/errors.js"
7
+ import { isNullable, isObject } from "./Predicate.js"
7
8
  import type * as Types from "./Types.js"
8
9
 
9
10
  /*
@@ -41,6 +42,12 @@ export interface GenKind<F extends TypeLambda, R, O, E, A> extends Variance<F, R
41
42
  [Symbol.iterator](): Generator<GenKind<F, R, O, E, A>, A>
42
43
  }
43
44
 
45
+ /**
46
+ * @category predicates
47
+ * @since 3.0.6
48
+ */
49
+ export const isGenKind = (u: unknown): u is GenKind<any, any, any, any, any> => isObject(u) && GenKindTypeId in u
50
+
44
51
  /**
45
52
  * @category constructors
46
53
  * @since 2.0.0
@@ -173,13 +180,19 @@ export interface Variance<in out F extends TypeLambda, in R, out O, out E> {
173
180
  * @since 2.0.0
174
181
  */
175
182
  export interface Gen<F extends TypeLambda, Z> {
176
- <K extends Variance<F, any, any, any> | Kind<F, any, any, any, any>, A>(
177
- body: (resume: Z) => Generator<K, A>
183
+ <K extends Variance<F, any, any, any> | YieldWrap<Kind<F, any, any, any, any>>, A>(
184
+ body: (resume: Z) => Generator<K, A, never>
178
185
  ): Kind<
179
186
  F,
180
- [K] extends [Variance<F, infer R, any, any>] ? R : [K] extends [Kind<F, infer R, any, any, any>] ? R : never,
181
- [K] extends [Variance<F, any, infer O, any>] ? O : [K] extends [Kind<F, any, infer O, any, any>] ? O : never,
182
- [K] extends [Variance<F, any, any, infer E>] ? E : [K] extends [Kind<F, any, any, infer E, any>] ? E : never,
187
+ [K] extends [Variance<F, infer R, any, any>] ? R
188
+ : [K] extends [YieldWrap<Kind<F, infer R, any, any, any>>] ? R
189
+ : never,
190
+ [K] extends [Variance<F, any, infer O, any>] ? O
191
+ : [K] extends [YieldWrap<Kind<F, any, infer O, any, any>>] ? O
192
+ : never,
193
+ [K] extends [Variance<F, any, any, infer E>] ? E
194
+ : [K] extends [YieldWrap<Kind<F, any, any, infer E, any>>] ? E
195
+ : never,
183
196
  A
184
197
  >
185
198
  }
@@ -191,22 +204,22 @@ export interface Gen<F extends TypeLambda, Z> {
191
204
  export interface Adapter<Z extends TypeLambda> {
192
205
  <_R, _O, _E, _A>(
193
206
  self: Kind<Z, _R, _O, _E, _A>
194
- ): Kind<Z, _R, _O, _E, _A>
195
- <A, _R, _O, _E, _A>(a: A, ab: (a: A) => Kind<Z, _R, _O, _E, _A>): Kind<Z, _R, _O, _E, _A>
196
- <A, B, _R, _O, _E, _A>(a: A, ab: (a: A) => B, bc: (b: B) => Kind<Z, _R, _O, _E, _A>): Kind<Z, _R, _O, _E, _A>
207
+ ): GenKind<Z, _R, _O, _E, _A>
208
+ <A, _R, _O, _E, _A>(a: A, ab: (a: A) => Kind<Z, _R, _O, _E, _A>): GenKind<Z, _R, _O, _E, _A>
209
+ <A, B, _R, _O, _E, _A>(a: A, ab: (a: A) => B, bc: (b: B) => Kind<Z, _R, _O, _E, _A>): GenKind<Z, _R, _O, _E, _A>
197
210
  <A, B, C, _R, _O, _E, _A>(
198
211
  a: A,
199
212
  ab: (a: A) => B,
200
213
  bc: (b: B) => C,
201
214
  cd: (c: C) => Kind<Z, _R, _O, _E, _A>
202
- ): Kind<Z, _R, _O, _E, _A>
215
+ ): GenKind<Z, _R, _O, _E, _A>
203
216
  <A, B, C, D, _R, _O, _E, _A>(
204
217
  a: A,
205
218
  ab: (a: A) => B,
206
219
  bc: (b: B) => C,
207
220
  cd: (c: C) => D,
208
221
  de: (d: D) => Kind<Z, _R, _O, _E, _A>
209
- ): Kind<Z, _R, _O, _E, _A>
222
+ ): GenKind<Z, _R, _O, _E, _A>
210
223
  <A, B, C, D, E, _R, _O, _E, _A>(
211
224
  a: A,
212
225
  ab: (a: A) => B,
@@ -214,7 +227,7 @@ export interface Adapter<Z extends TypeLambda> {
214
227
  cd: (c: C) => D,
215
228
  de: (d: D) => E,
216
229
  ef: (e: E) => Kind<Z, _R, _O, _E, _A>
217
- ): Kind<Z, _R, _O, _E, _A>
230
+ ): GenKind<Z, _R, _O, _E, _A>
218
231
  <A, B, C, D, E, F, _R, _O, _E, _A>(
219
232
  a: A,
220
233
  ab: (a: A) => B,
@@ -223,7 +236,7 @@ export interface Adapter<Z extends TypeLambda> {
223
236
  de: (d: D) => E,
224
237
  ef: (e: E) => F,
225
238
  fg: (f: F) => Kind<Z, _R, _O, _E, _A>
226
- ): Kind<Z, _R, _O, _E, _A>
239
+ ): GenKind<Z, _R, _O, _E, _A>
227
240
  <A, B, C, D, E, F, G, _R, _O, _E, _A>(
228
241
  a: A,
229
242
  ab: (a: A) => B,
@@ -233,7 +246,7 @@ export interface Adapter<Z extends TypeLambda> {
233
246
  ef: (e: E) => F,
234
247
  fg: (f: F) => G,
235
248
  gh: (g: F) => Kind<Z, _R, _O, _E, _A>
236
- ): Kind<Z, _R, _O, _E, _A>
249
+ ): GenKind<Z, _R, _O, _E, _A>
237
250
  <A, B, C, D, E, F, G, H, _R, _O, _E, _A>(
238
251
  a: A,
239
252
  ab: (a: A) => B,
@@ -244,7 +257,7 @@ export interface Adapter<Z extends TypeLambda> {
244
257
  fg: (f: F) => G,
245
258
  gh: (g: G) => H,
246
259
  hi: (g: H) => Kind<Z, _R, _O, _E, _A>
247
- ): Kind<Z, _R, _O, _E, _A>
260
+ ): GenKind<Z, _R, _O, _E, _A>
248
261
  <A, B, C, D, E, F, G, H, I, _R, _O, _E, _A>(
249
262
  a: A,
250
263
  ab: (a: A) => B,
@@ -256,7 +269,7 @@ export interface Adapter<Z extends TypeLambda> {
256
269
  gh: (g: G) => H,
257
270
  hi: (h: H) => I,
258
271
  ij: (i: I) => Kind<Z, _R, _O, _E, _A>
259
- ): Kind<Z, _R, _O, _E, _A>
272
+ ): GenKind<Z, _R, _O, _E, _A>
260
273
  <A, B, C, D, E, F, G, H, I, J, _R, _O, _E, _A>(
261
274
  a: A,
262
275
  ab: (a: A) => B,
@@ -269,7 +282,7 @@ export interface Adapter<Z extends TypeLambda> {
269
282
  hi: (h: H) => I,
270
283
  ij: (i: I) => J,
271
284
  jk: (j: J) => Kind<Z, _R, _O, _E, _A>
272
- ): Kind<Z, _R, _O, _E, _A>
285
+ ): GenKind<Z, _R, _O, _E, _A>
273
286
  <A, B, C, D, E, F, G, H, I, J, K, _R, _O, _E, _A>(
274
287
  a: A,
275
288
  ab: (a: A) => B,
@@ -283,7 +296,7 @@ export interface Adapter<Z extends TypeLambda> {
283
296
  ij: (i: I) => J,
284
297
  jk: (j: J) => K,
285
298
  kl: (k: K) => Kind<Z, _R, _O, _E, _A>
286
- ): Kind<Z, _R, _O, _E, _A>
299
+ ): GenKind<Z, _R, _O, _E, _A>
287
300
  <A, B, C, D, E, F, G, H, I, J, K, L, _R, _O, _E, _A>(
288
301
  a: A,
289
302
  ab: (a: A) => B,
@@ -298,7 +311,7 @@ export interface Adapter<Z extends TypeLambda> {
298
311
  jk: (j: J) => K,
299
312
  kl: (k: K) => L,
300
313
  lm: (l: L) => Kind<Z, _R, _O, _E, _A>
301
- ): Kind<Z, _R, _O, _E, _A>
314
+ ): GenKind<Z, _R, _O, _E, _A>
302
315
  <A, B, C, D, E, F, G, H, I, J, K, L, M, _R, _O, _E, _A>(
303
316
  a: A,
304
317
  ab: (a: A) => B,
@@ -314,7 +327,7 @@ export interface Adapter<Z extends TypeLambda> {
314
327
  kl: (k: K) => L,
315
328
  lm: (l: L) => M,
316
329
  mn: (m: M) => Kind<Z, _R, _O, _E, _A>
317
- ): Kind<Z, _R, _O, _E, _A>
330
+ ): GenKind<Z, _R, _O, _E, _A>
318
331
  <A, B, C, D, E, F, G, H, I, J, K, L, M, N, _R, _O, _E, _A>(
319
332
  a: A,
320
333
  ab: (a: A) => B,
@@ -331,7 +344,7 @@ export interface Adapter<Z extends TypeLambda> {
331
344
  lm: (l: L) => M,
332
345
  mn: (m: M) => N,
333
346
  no: (n: N) => Kind<Z, _R, _O, _E, _A>
334
- ): Kind<Z, _R, _O, _E, _A>
347
+ ): GenKind<Z, _R, _O, _E, _A>
335
348
  <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, _R, _O, _E, _A>(
336
349
  a: A,
337
350
  ab: (a: A) => B,
@@ -349,7 +362,7 @@ export interface Adapter<Z extends TypeLambda> {
349
362
  mn: (m: M) => N,
350
363
  no: (n: N) => O,
351
364
  op: (o: O) => Kind<Z, _R, _O, _E, _A>
352
- ): Kind<Z, _R, _O, _E, _A>
365
+ ): GenKind<Z, _R, _O, _E, _A>
353
366
  <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, _R, _O, _E, _A>(
354
367
  a: A,
355
368
  ab: (a: A) => B,
@@ -368,7 +381,7 @@ export interface Adapter<Z extends TypeLambda> {
368
381
  no: (n: N) => O,
369
382
  op: (o: O) => P,
370
383
  pq: (p: P) => Kind<Z, _R, _O, _E, _A>
371
- ): Kind<Z, _R, _O, _E, _A>
384
+ ): GenKind<Z, _R, _O, _E, _A>
372
385
  <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, _R, _O, _E, _A>(
373
386
  a: A,
374
387
  ab: (a: A) => B,
@@ -388,7 +401,7 @@ export interface Adapter<Z extends TypeLambda> {
388
401
  op: (o: O) => P,
389
402
  pq: (p: P) => Q,
390
403
  qr: (q: Q) => Kind<Z, _R, _O, _E, _A>
391
- ): Kind<Z, _R, _O, _E, _A>
404
+ ): GenKind<Z, _R, _O, _E, _A>
392
405
  <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, _R, _O, _E, _A>(
393
406
  a: A,
394
407
  ab: (a: A) => B,
@@ -409,7 +422,7 @@ export interface Adapter<Z extends TypeLambda> {
409
422
  pq: (p: P) => Q,
410
423
  qr: (q: Q) => R,
411
424
  rs: (r: R) => Kind<Z, _R, _O, _E, _A>
412
- ): Kind<Z, _R, _O, _E, _A>
425
+ ): GenKind<Z, _R, _O, _E, _A>
413
426
  <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, _R, _O, _E, _A>(
414
427
  a: A,
415
428
  ab: (a: A) => B,
@@ -431,7 +444,7 @@ export interface Adapter<Z extends TypeLambda> {
431
444
  qr: (q: Q) => R,
432
445
  rs: (r: R) => S,
433
446
  st: (s: S) => Kind<Z, _R, _O, _E, _A>
434
- ): Kind<Z, _R, _O, _E, _A>
447
+ ): GenKind<Z, _R, _O, _E, _A>
435
448
  <A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, _R, _O, _E, _A>(
436
449
  a: A,
437
450
  ab: (a: A) => B,
@@ -454,7 +467,7 @@ export interface Adapter<Z extends TypeLambda> {
454
467
  rs: (r: R) => S,
455
468
  st: (s: S) => T,
456
469
  tu: (s: T) => Kind<Z, _R, _O, _E, _A>
457
- ): Kind<Z, _R, _O, _E, _A>
470
+ ): GenKind<Z, _R, _O, _E, _A>
458
471
  }
459
472
 
460
473
  /**
@@ -466,7 +479,7 @@ export const adapter: <F extends TypeLambda>() => Adapter<F> = () => (function()
466
479
  for (let i = 1; i < arguments.length; i++) {
467
480
  x = arguments[i](x)
468
481
  }
469
- return x
482
+ return new GenKindImpl(x) as any
470
483
  })
471
484
 
472
485
  const defaultIncHi = 0x14057b7e
@@ -699,3 +712,37 @@ function add64(
699
712
  out[0] = hi
700
713
  out[1] = lo
701
714
  }
715
+
716
+ /**
717
+ * @since 3.0.6
718
+ */
719
+ export const YieldWrapTypeId = Symbol.for("effect/Utils/YieldWrap")
720
+
721
+ /**
722
+ * @since 3.0.6
723
+ */
724
+ export class YieldWrap<T> {
725
+ /**
726
+ * @since 3.0.6
727
+ */
728
+ readonly #value: T
729
+ constructor(value: T) {
730
+ this.#value = value
731
+ }
732
+ /**
733
+ * @since 3.0.6
734
+ */
735
+ [YieldWrapTypeId](): T {
736
+ return this.#value
737
+ }
738
+ }
739
+
740
+ /**
741
+ * @since 3.0.6
742
+ */
743
+ export function yieldWrapGet<T>(self: YieldWrap<T>): T {
744
+ if (typeof self === "object" && self !== null && YieldWrapTypeId in self) {
745
+ return self[YieldWrapTypeId]()
746
+ }
747
+ throw new Error(getBugErrorMessage("yieldWrapGet"))
748
+ }
@@ -13,6 +13,7 @@ import { pipeArguments } from "../Pipeable.js"
13
13
  import { hasProperty, isFunction } from "../Predicate.js"
14
14
  import type { Predicate, Refinement } from "../Predicate.js"
15
15
  import type { AnySpan, Span } from "../Tracer.js"
16
+ import type { NoInfer } from "../Types.js"
16
17
  import { getBugErrorMessage } from "./errors.js"
17
18
  import * as OpCodes from "./opCodes/cause.js"
18
19
 
@@ -25,7 +25,8 @@ import type * as Random from "../Random.js"
25
25
  import * as Ref from "../Ref.js"
26
26
  import type * as runtimeFlagsPatch from "../RuntimeFlagsPatch.js"
27
27
  import * as Tracer from "../Tracer.js"
28
- import type { MergeRecord } from "../Types.js"
28
+ import type { MergeRecord, NoInfer } from "../Types.js"
29
+ import { yieldWrapGet } from "../Utils.js"
29
30
  import * as internalCause from "./cause.js"
30
31
  import { clockTag } from "./clock.js"
31
32
  import * as core from "./core.js"
@@ -788,9 +789,11 @@ export const gen: typeof Effect.gen = function() {
788
789
  const state = iterator.next()
789
790
  const run = (
790
791
  state: IteratorYieldResult<any> | IteratorReturnResult<any>
791
- ): Effect.Effect<any, any, any> => (state.done
792
- ? core.succeed(state.value)
793
- : core.flatMap(state.value, (val: any) => run(iterator.next(val))))
792
+ ): Effect.Effect<any, any, any> => {
793
+ return (state.done
794
+ ? core.succeed(state.value)
795
+ : core.flatMap(yieldWrapGet(state.value) as any, (val: any) => run(iterator.next(val))))
796
+ }
794
797
  return run(state)
795
798
  })
796
799
  }
@@ -35,7 +35,8 @@ import type * as RuntimeFlags from "../RuntimeFlags.js"
35
35
  import * as RuntimeFlagsPatch from "../RuntimeFlagsPatch.js"
36
36
  import type * as Scope from "../Scope.js"
37
37
  import type * as Tracer from "../Tracer.js"
38
- import type { NotFunction } from "../Types.js"
38
+ import type { NoInfer, NotFunction } from "../Types.js"
39
+ import { YieldWrap } from "../Utils.js"
39
40
  import * as _blockedRequests from "./blockedRequests.js"
40
41
  import * as internalCause from "./cause.js"
41
42
  import * as deferred from "./deferred.js"
@@ -180,7 +181,7 @@ class EffectPrimitive {
180
181
  return this.toJSON()
181
182
  }
182
183
  [Symbol.iterator]() {
183
- return new SingleShotGen(this)
184
+ return new SingleShotGen(new YieldWrap(this))
184
185
  }
185
186
  }
186
187
 
@@ -221,7 +222,7 @@ class EffectPrimitiveFailure {
221
222
  return this.toJSON()
222
223
  }
223
224
  [Symbol.iterator]() {
224
- return new SingleShotGen(this)
225
+ return new SingleShotGen(new YieldWrap(this))
225
226
  }
226
227
  }
227
228
 
@@ -262,7 +263,7 @@ class EffectPrimitiveSuccess {
262
263
  return this.toJSON()
263
264
  }
264
265
  [Symbol.iterator]() {
265
- return new SingleShotGen(this)
266
+ return new SingleShotGen(new YieldWrap(this))
266
267
  }
267
268
  }
268
269
 
@@ -7,6 +7,7 @@ import type * as Either from "../Either.js"
7
7
  import { dual, pipe } from "../Function.js"
8
8
  import type * as Request from "../Request.js"
9
9
  import type * as RequestResolver from "../RequestResolver.js"
10
+ import type { NoInfer } from "../Types.js"
10
11
  import * as core from "./core.js"
11
12
  import { invokeWithInterrupt, zipWithOptions } from "./fiberRuntime.js"
12
13
  import { complete } from "./request.js"
@@ -24,21 +25,21 @@ export const makeWithEntry = <A, R>(
24
25
 
25
26
  /** @internal */
26
27
  export const makeBatched = <A extends Request.Request<any, any>, R>(
27
- run: (requests: Array<A>) => Effect.Effect<void, never, R>
28
+ run: (requests: RA.NonEmptyArray<A>) => Effect.Effect<void, never, R>
28
29
  ): RequestResolver.RequestResolver<A, R> =>
29
30
  new core.RequestResolverImpl<A, R>(
30
31
  (requests) => {
31
32
  if (requests.length > 1) {
32
33
  return core.forEachSequentialDiscard(requests, (block) => {
33
34
  const filtered = block.filter((_) => !_.state.completed).map((_) => _.request)
34
- if (filtered.length === 0) {
35
+ if (!RA.isNonEmptyArray(filtered)) {
35
36
  return core.void
36
37
  }
37
38
  return invokeWithInterrupt(run(filtered), block)
38
39
  })
39
40
  } else if (requests.length === 1) {
40
41
  const filtered = requests[0].filter((_) => !_.state.completed).map((_) => _.request)
41
- if (filtered.length === 0) {
42
+ if (!RA.isNonEmptyArray(filtered)) {
42
43
  return core.void
43
44
  }
44
45
  return run(filtered)
@@ -210,7 +211,7 @@ export const eitherWith = dual<
210
211
  export const fromFunction = <A extends Request.Request<any>>(
211
212
  f: (request: A) => Request.Request.Success<A>
212
213
  ): RequestResolver.RequestResolver<A> =>
213
- makeBatched((requests: Array<A>) =>
214
+ makeBatched((requests: RA.NonEmptyArray<A>) =>
214
215
  core.forEachSequentialDiscard(
215
216
  requests,
216
217
  (request) => complete(request, core.exitSucceed(f(request)) as any)
@@ -219,9 +220,9 @@ export const fromFunction = <A extends Request.Request<any>>(
219
220
 
220
221
  /** @internal */
221
222
  export const fromFunctionBatched = <A extends Request.Request<any>>(
222
- f: (chunk: Array<A>) => Iterable<Request.Request.Success<A>>
223
+ f: (chunk: RA.NonEmptyArray<A>) => Iterable<Request.Request.Success<A>>
223
224
  ): RequestResolver.RequestResolver<A> =>
224
- makeBatched((as: Array<A>) =>
225
+ makeBatched((as: RA.NonEmptyArray<A>) =>
225
226
  Effect.forEach(
226
227
  f(as),
227
228
  (res, i) => complete(as[i], core.exitSucceed(res) as any),
@@ -233,7 +234,7 @@ export const fromFunctionBatched = <A extends Request.Request<any>>(
233
234
  export const fromEffect = <R, A extends Request.Request<any, any>>(
234
235
  f: (a: A) => Effect.Effect<Request.Request.Success<A>, Request.Request.Error<A>, R>
235
236
  ): RequestResolver.RequestResolver<A, R> =>
236
- makeBatched((requests: Array<A>) =>
237
+ makeBatched((requests: RA.NonEmptyArray<A>) =>
237
238
  Effect.forEach(
238
239
  requests,
239
240
  (a) => Effect.flatMap(Effect.exit(f(a)), (e) => complete(a, e as any)),
@@ -261,7 +262,7 @@ export const fromEffectTagged = <
261
262
  A,
262
263
  ReturnType<Fns[keyof Fns]> extends Effect.Effect<infer _A, infer _E, infer R> ? R : never
263
264
  > =>
264
- makeBatched<A, any>((requests: Array<A>) => {
265
+ makeBatched<A, any>((requests: RA.NonEmptyArray<A>) => {
265
266
  const grouped: Record<string, Array<A>> = {}
266
267
  const tags: Array<A["_tag"]> = []
267
268
  for (let i = 0, len = requests.length; i < len; i++) {
@@ -6,8 +6,8 @@ import * as Hash from "../Hash.js"
6
6
  import { pipeArguments } from "../Pipeable.js"
7
7
  import type * as Sink from "../Sink.js"
8
8
  import type * as Stream from "../Stream.js"
9
+ import { SingleShotGen, YieldWrap } from "../Utils.js"
9
10
  import * as OpCodes from "./opCodes/effect.js"
10
- import * as SingleShotGen from "./singleShotGen.js"
11
11
  import * as version from "./version.js"
12
12
 
13
13
  /** @internal */
@@ -77,7 +77,7 @@ export const EffectPrototype: Effect.Effect<never> & Equal.Equal = {
77
77
  return Hash.cached(this, Hash.random(this))
78
78
  },
79
79
  [Symbol.iterator]() {
80
- return new SingleShotGen.SingleShotGen(this) as any
80
+ return new SingleShotGen(new YieldWrap(this)) as any
81
81
  },
82
82
  pipe() {
83
83
  return pipeArguments(this, arguments)
@@ -41,7 +41,7 @@ import { currentScheduler, type Scheduler } from "../Scheduler.js"
41
41
  import type * as Scope from "../Scope.js"
42
42
  import type * as Supervisor from "../Supervisor.js"
43
43
  import type * as Tracer from "../Tracer.js"
44
- import type { Concurrency } from "../Types.js"
44
+ import type { Concurrency, NoInfer } from "../Types.js"
45
45
  import * as _RequestBlock from "./blockedRequests.js"
46
46
  import * as internalCause from "./cause.js"
47
47
  import * as clock from "./clock.js"
@@ -1883,14 +1883,16 @@ export const replicateEffect: {
1883
1883
 
1884
1884
  /* @internal */
1885
1885
  export const forEach: {
1886
- <A, B, E, R>(
1887
- f: (a: A, i: number) => Effect.Effect<B, E, R>,
1886
+ <B, E, R, S extends Iterable<any>>(
1887
+ f: (a: RA.ReadonlyArray.Infer<S>, i: number) => Effect.Effect<B, E, R>,
1888
1888
  options?: {
1889
1889
  readonly concurrency?: Concurrency | undefined
1890
1890
  readonly batching?: boolean | "inherit" | undefined
1891
1891
  readonly discard?: false | undefined
1892
- }
1893
- ): (self: Iterable<A>) => Effect.Effect<Array<B>, E, R>
1892
+ } | undefined
1893
+ ): (
1894
+ self: S
1895
+ ) => Effect.Effect<RA.ReadonlyArray.With<S, B>, E, R>
1894
1896
  <A, B, E, R>(
1895
1897
  f: (a: A, i: number) => Effect.Effect<B, E, R>,
1896
1898
  options: {
@@ -1899,6 +1901,15 @@ export const forEach: {
1899
1901
  readonly discard: true
1900
1902
  }
1901
1903
  ): (self: Iterable<A>) => Effect.Effect<void, E, R>
1904
+ <A, B, E, R>(
1905
+ self: RA.NonEmptyReadonlyArray<A>,
1906
+ f: (a: A, i: number) => Effect.Effect<B, E, R>,
1907
+ options?: {
1908
+ readonly concurrency?: Concurrency | undefined
1909
+ readonly batching?: boolean | "inherit" | undefined
1910
+ readonly discard?: false | undefined
1911
+ } | undefined
1912
+ ): Effect.Effect<RA.NonEmptyArray<B>, E, R>
1902
1913
  <A, B, E, R>(
1903
1914
  self: Iterable<A>,
1904
1915
  f: (a: A, i: number) => Effect.Effect<B, E, R>,
@@ -1906,7 +1917,7 @@ export const forEach: {
1906
1917
  readonly concurrency?: Concurrency | undefined
1907
1918
  readonly batching?: boolean | "inherit" | undefined
1908
1919
  readonly discard?: false | undefined
1909
- }
1920
+ } | undefined
1910
1921
  ): Effect.Effect<Array<B>, E, R>
1911
1922
  <A, B, E, R>(
1912
1923
  self: Iterable<A>,
@@ -13,7 +13,7 @@ import * as Queue from "../Queue.js"
13
13
  import * as Ref from "../Ref.js"
14
14
  import type * as Stream from "../Stream.js"
15
15
  import type * as Take from "../Take.js"
16
- import type { MergeRecord } from "../Types.js"
16
+ import type { MergeRecord, NoInfer } from "../Types.js"
17
17
  import * as channel from "./channel.js"
18
18
  import * as channelExecutor from "./channel/channelExecutor.js"
19
19
  import * as core from "./core-stream.js"
@@ -7,6 +7,7 @@ import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js"
7
7
  import * as Option from "../Option.js"
8
8
  import { pipeArguments } from "../Pipeable.js"
9
9
  import { hasProperty } from "../Predicate.js"
10
+ import type { NoInfer } from "../Types.js"
10
11
  import { fromBitmap, hashFragment, toBitmap } from "./hashMap/bitwise.js"
11
12
  import { SIZE } from "./hashMap/config.js"
12
13
  import * as Node from "./hashMap/node.js"
@@ -7,6 +7,7 @@ import { format, NodeInspectSymbol, toJSON } from "../Inspectable.js"
7
7
  import { pipeArguments } from "../Pipeable.js"
8
8
  import type { Predicate, Refinement } from "../Predicate.js"
9
9
  import { hasProperty } from "../Predicate.js"
10
+ import type { NoInfer } from "../Types.js"
10
11
  import * as HM from "./hashMap.js"
11
12
 
12
13
  const HashSetSymbolKey = "effect/HashSet"